説明したように a を使用する方法を示す XAML を次に示しますGridSplitter
。
<Grid VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="10" />
<RowDefinition Height="10" />
<RowDefinition Height="10" />
<RowDefinition Height="10" />
<RowDefinition Height="10" />
<RowDefinition Height="10" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Rectangle Grid.Row="0" Fill="Red" />
<Rectangle Grid.Row="1" Fill="Orange" />
<Rectangle Grid.Row="2" Fill="Yellow" />
<Rectangle Grid.Row="3" Fill="Green" />
<Rectangle Grid.Row="4" Fill="Blue" />
<Rectangle Grid.Row="5" Fill="LightBlue" />
<ListBox Grid.Row="6" Background="Indigo">
<ListBoxItem>Hello</ListBoxItem>
<ListBoxItem>World</ListBoxItem>
</ListBox>
<GridSplitter Grid.Row="7" Height="5" Background="Gray"
VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<ListBox Grid.Row="7" Background="Violet" Margin="0,5,0,0">
<ListBoxItem>Hello</ListBoxItem>
<ListBoxItem>World</ListBoxItem>
</ListBox>
</Grid>
GridSplitter を独自の行に配置しないでください。それを既存の行内に配置し、配置を上 (上のセルの場合は下) に設定し、水平に引き伸ばします。高さを 5 に設定し、2 番目の ListBox の上マージンを 5 に設定して、どちらの要素も他の要素を隠していないことに注意してください。
それが役立つことを願っています。