C# 如何将虚拟化ListView放入StackPanel或弹出型按钮中?
我有一个C# 如何将虚拟化ListView放入StackPanel或弹出型按钮中?,c#,xaml,windows-phone-8,windows-runtime,windows-phone-8.1,C#,Xaml,Windows Phone 8,Windows Runtime,Windows Phone 8.1,我有一个列表视图在一个弹出式按钮内,而弹出式按钮像StackPanel一样高度无限,因此列表视图失去了虚拟化 <Flyout Placement="Full"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="auto"/> <RowDefinition Height="*"/> </Gr
列表视图
在一个弹出式按钮
内,而弹出式按钮
像StackPanel
一样高度无限,因此列表视图失去了虚拟化
<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>
我可以给网格一个固定的Height=500
,但它可能会根据不同的分辨率而改变
我需要获得页面高度并在装订中设置它,但我不知道如何获得它
如何限制ListView的高度?您可以订阅页面的SizeChanged事件,并从代码隐藏设置高度:
private void PhoneApplicationPage_SizeChanged(object sender, SizeChangedEventArgs e)
{
//Set the <Grid Name="GridInsideFlyout"> in XAML
GridInsideFlyout.Height = e.NewSize.Height;
}
private void phoneapplication页面\u SizeChanged(对象发送方,sizechangedventargs e)
{
//在XAML中设置
GridInsideFlyout.Height=e.NewSize.Height;
}
您可以使用{Binding Height,UpdateSourceTrigger=PropertyChanged}”