具有少量项目的ListView不可滚动

时间:2014-09-13 21:51:24

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

我有一个非常常见的ListView(在一个非常常见的Windows Universal应用程序中),它放在一个非常常见的网页上。

<Grid Margin="12,24,12,0">

    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <ListView 
            ItemTemplate="{StaticResource AccountsItemTemplate}"
            ItemsSource="{Binding AccountList}" /> 
</Grid>

事情是:如果我有3-5个项目(因此它们都适合屏幕),滚动条被禁用。如果我有十几个,那么滚动条已启用,一切都很好。

如何强制滚动条出现在小于屏幕尺寸的列表视图中?

1 个答案:

答案 0 :(得分:2)

将ScrollViewer.VerticalScrollMode设置为Enabled,即使所有项目都适合屏幕并且不需要滚动,也可以垂直滚动(实际上拉和下拉)。

<ListView ScrollViewer.VerticalScrollMode="Enabled"
          ItemTemplate="{StaticResource AccountsItemTemplate}"
          ItemsSource="{Binding AccountList}" />