ContentDialog中的UWP ListView不滚动

时间:2016-04-08 15:26:38

标签: c# win-universal-app windows-10-universal uwp-xaml

C#UWP Windows 10

这是我的contentdialog的XAML代码:

 <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>

    .....

    <Grid Grid.Row="1" Grid.ColumnSpan="2">
        <ListView x:Name="MerchantList"                
            ItemTemplate="{StaticResource MerchantListViewTemplate}"
            SelectionMode="Single"
            SelectedValue="{Binding currItemId, Mode=TwoWay}"
            SelectedValuePath="Id"
            ShowsScrollingPlaceholders="True">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                    <Setter Property="Margin" Value="0"/>
                    <Setter Property="Padding" Value="0"/>
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
    </Grid>
</Grid>

我需要向用户显示一些项目列表,但ListView不能滚动。如何解决?

2 个答案:

答案 0 :(得分:2)

尝试设置一些“非自动”大小的列和行(像素或星形,无关紧要)。我真的无法在文档中找出这种行为的任何原因,但在我的情况下它有所帮助。

答案 1 :(得分:0)

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>



    <Grid Grid.Row="1" Grid.ColumnSpan="2">
        <ScrollViewer VerticalScrollMode="Enabled" HorizontalScrollMode="Enabled" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
        <ListView x:Name="MerchantList"                
        ItemTemplate="{StaticResource MerchantListViewTemplate}"
        SelectionMode="Single"
        SelectedValue="{Binding currItemId, Mode=TwoWay}"
        SelectedValuePath="Id"
        ShowsScrollingPlaceholders="True">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                    <Setter Property="Margin" Value="0"/>
                    <Setter Property="Padding" Value="0"/>
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        </ScrollViewer>
    </Grid>
</Grid>

试试这个......