我在 flyout
和 flyout
中有一个 ListView
像 StackPanel
有无限的高度所以 ListView 失去了虚拟化.
<Flyout Placement="Full">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="All Players" Margin="12"/>
<ListView Grid.Row="1" Margin="12"/>
</Grid>
</Flyout>
我可以给 Grid 一个固定的 Height = 500
,但它可能会在不同的分辨率下发生变化。
我需要获取页面高度并在绑定(bind)中设置它,但我不知道如何获取它!
如何限制ListView的高度?
最佳答案
您可以订阅 Page 的 SizeChanged 事件并从后面的代码中设置高度:
private void PhoneApplicationPage_SizeChanged(object sender, SizeChangedEventArgs e)
{
//Set the <Grid Name="GridInsideFlyout"> in XAML
GridInsideFlyout.Height = e.NewSize.Height;
}
关于c# - 如何将虚拟化 ListView 放入 StackPanel 或 Flyout 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24773943/