我有一些 XAML 代码,我的问题是 Listview 高度没有保持在 Grid 行的范围内,而是随着 ListViewItem 添加的数量而增长。这可以防止列表滚动。
我怎样才能防止这种情况?
这是一些复制的 xaml 代码:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid Margin="30, 20, 30, 20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<TextBlock Text="SomeText" FontSize="40"/>
</StackPanel>
<StackPanel Grid.Row="1">
<TextBlock Text="Some More Text" FontSize="30"/>
</StackPanel>
<Grid x:Name="ContGrid" Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Viewbox HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Stretch="None" Width="AUto">
<StackPanel x:Name="holderPanel" Margin="5" Grid.Column="0" Grid.Row="0" Orientation="Vertical">
<TextBlock Text="SomeCategories" FontSize="20"/>
<ListView CanDragItems="True" CanReorderItems="True" AllowDrop="True" Width="380">
<ListViewItem Background="Blue">Test</ListViewItem>
<ListViewItem Background="Red">Test</ListViewItem>
<ListViewItem Background="Green">Test</ListViewItem>
<ListViewItem Background="Purple">Test</ListViewItem>
<ListViewItem Background="Blue">Test</ListViewItem>
<ListViewItem Background="Red">Test</ListViewItem>
<ListViewItem Background="Blue">Test</ListViewItem>
<ListViewItem Background="Red">Test</ListViewItem>
<ListViewItem Background="Green">Test</ListViewItem>
<ListViewItem Background="Purple">Test</ListViewItem>
<ListViewItem Background="Blue">Test</ListViewItem>
<ListViewItem Background="Red">Test</ListViewItem>
<ListViewItem Background="Blue">Test</ListViewItem>
<ListViewItem Background="Red">Test</ListViewItem>
<ListViewItem Background="Green">Test</ListViewItem>
<ListViewItem Background="Purple">Test</ListViewItem>
<ListViewItem Background="Blue">Test</ListViewItem>
<ListViewItem Background="Red">Test</ListViewItem>
<ListViewItem Background="Blue">Test</ListViewItem>
<ListViewItem Background="Red">Test</ListViewItem>
<ListViewItem Background="Green">Test</ListViewItem>
<ListViewItem Background="Purple">Test</ListViewItem>
<ListViewItem Background="Blue">Test</ListViewItem>
<ListViewItem Background="Red">Test</ListViewItem>
</ListView>
</StackPanel>
</Viewbox>
</Grid>
</Grid>
</Grid>