考慮以下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>
第二行中的列表框中顯示了垂直滾動條的禁止,只是切斷內容。
我希望它被限制在窗口的可見區域。如何實現這一目標?
理性背後的第二個網格行的高度設置爲自動: 我想第二個列表框,以顯示其所有內容,而無需滾動條如果有足夠的空間供其和第一ListBox中應該採取的剩餘空間。
第一個'listBox'應該佔用剩餘空間,第二個應占用可用空間。但是需要限制其他人進行評估。不是嗎? –
有一個約束,首先ListBox有一個MinHeight設置爲100. – Sisyphe