如何在StackPanel或Flyout中放置一个虚拟化的ListView



我有一个ListView里面的flyoutflyoutStackPanel有无限的高度,所以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>

我可以给一个固定的Height = 500网格,但它可能会改变不同的分辨率。

我需要得到页面高度并在绑定中设置它,但我不知道如何得到它!

如何限制ListView的高度?

您可以订阅页面的sizechange事件,并从后面的代码设置高度:

    private void PhoneApplicationPage_SizeChanged(object sender, SizeChangedEventArgs e)
    {
        //Set the <Grid Name="GridInsideFlyout"> in XAML
        GridInsideFlyout.Height = e.NewSize.Height;
    }

相关内容

最新更新