次のXAMLを検討してください。
<Window x:Class="WpfApplication4.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" MinHeight="100" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListBox>
<ListBox.Items>
<ListBoxItem>a</ListBoxItem>
<!-- Another 11 items -->
</ListBox.Items>
</ListBox>
<ListBox Grid.Row="1" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListBox.Items>
<ListBoxItem>1</ListBoxItem>
<!-- Another 23 items -->
</ListBox.Items>
</ListBox>
</Grid>
</Window>
2行目のListBoxは、垂直スクロールバーが無効になっていることを示しており、単にコンテンツを切り取っています。
ウィンドウの表示領域に制限する必要があります。これを達成する方法は?
2番目のグリッド行の高さを[自動]に設定する理由:十分なスペースがあり、最初のリストボックスが残りのスペースを取る必要がある場合、2番目のリストボックスにスクロールバーなしですべてのコンテンツを表示する必要があります。