【问题标题】:How to put a Virtualized ListView inside a StackPanel or Flyout?如何将虚拟化 ListView 放入 StackPanel 或 Flyout?
【发布时间】:2014-07-16 06:45:16
【问题描述】:

我在flyoutflyout 中有一个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,但它可能会因不同的分辨率而改变。

我需要获取页面高度并将其设置为绑定,但我不知道如何获取它!

如何限制 ListView 的高度?

【问题讨论】:

  • 您可以使用 {Binding Height, UpdateSourceTrigger=PropertyChanged}"

标签: c# xaml windows-phone-8 windows-runtime windows-phone-8.1


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-17
    • 2020-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多