--- lang: ja-jp breaks: true --- # `WinUI 3` StackPanel に追加した最後のコントロールが残りの全ての領域に描画されるようにするには 2022-11-28 > How to get StackPanel's children to fill maximum space downward? > https://stackoverflow.com/questions/569095/how-to-get-stackpanels-children-to-fill-maximum-space-downward ## `WindowsCommunityToolkit` の `DockPanel` を使用する ![](https://i.imgur.com/5jFpWXN.png) ### `csproj` ```xml= <Project Sdk="Microsoft.NET.Sdk"> ・・・ <ItemGroup> <PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" /> </ItemGroup> ・・・ </Project> ``` ### MainWindow.xaml ```xml= <Window x:Class="PanelTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:PanelTest" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls" > <Grid BorderBrush="Blue" BorderThickness="2" > <controls:DockPanel > <Button controls:DockPanel.Dock="Left" BorderBrush="Green" BorderThickness="2" > Click Me </Button> <Button controls:DockPanel.Dock="Left" BorderBrush="Yellow" BorderThickness="2" > Click Me </Button> <StackPanel controls:DockPanel.Dock="Left" Margin="10" Width="Auto" BorderBrush="Red" BorderThickness="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" > <TextBlock Text="Here is the news that should wrap around." TextWrapping="Wrap"/> </StackPanel> </controls:DockPanel> </Grid> </Window> ``` ###### tags: `WinUI 3` `StackPanel` `WindowsCommunityToolkit` `DockPanel`