XAML(WP8.1)可滚动ListView和DataTemplate的固定Grid底部

时间:2015-10-01 16:07:17

标签: xaml windows-phone-8.1 windows-phone

<DataTemplate>
    <ScrollViewer>
        <Grid>
            ... same rows and controls 20% of screen
        </Grid>
        <ListView>
        </ListView>
    </ScrollViewer>
</DataTemplate>

使用此模板

  1. 首先修复网格

  2. 可滚动ListView第二

  3. 如何使用

    创建模板
    1. 顶部的可滚动ListView

    2. 在底部固定网格

    3. P.S。有在线或编译演示不同的xaml布局/模板吗?

1 个答案:

答案 0 :(得分:1)

不要将ListView放在ScrollViewer内,因为如果使用虚拟机会丢失虚拟化,这会显着降低性能。

如果您希望Grid始终可见,请使用以下内容:

<DataTemplate>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <ListView Grid.Row="0"/>
        <Grid Grid.Row="1" Height="100"/> <!-- Set any fixed height -->
    </Grid>
</DataTemplate>

如果您希望Grid滚动列表,请使用Footer

<DataTemplate>
    <ListView>
        <ListView.Footer>
            <!-- Set any fixed height -->
            <Grid Height="100"/>
        </ListView.Footer>
    </ListView>
</DataTemplate>
相关问题