WrapGrid 水平滚动 Windows 8。

4

我有一个主网格的XAML代码:

<ListView Grid.Row="1" x:Name="NewsListBox">
            <ListView.Background>
                <SolidColorBrush Color="#FF006C67" Opacity="0.5"/>
            </ListView.Background>
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapGrid Orientation="Vertical"/>
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
        </ListView>

它看起来很好,就像需要的那样:

但它不会滚动内容!

示例

好的,我添加了 ScrollViewer:

<ScrollViewer Grid.Row="1" VerticalScrollMode="Disabled" ZoomMode="Disabled">
        <ListView Grid.Row="1" x:Name="NewsListBox">
            <ListView.Background>
                <SolidColorBrush Color="#FF006C67" Opacity="0.5"/>
            </ListView.Background>
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapGrid Orientation="Vertical"/>
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
        </ListView>
        </ScrollViewer>

它将所有内容垂直堆叠:

示例

我做错了什么?

2个回答

5

找到了解决方案。不需要使用ScrollViewer。

只需将ListView替换为GridView,因为ListView不适用于水平滚动。


实际上,您可以通过自定义ItemsPanelTemplate来改变ListView的行为,使其类似于GridView。它们甚至使用相同的样式资源。 - VasileF

1

你可以尝试这个

<ListView
    ScrollViewer.HorizontalScrollMode="Enabled"
    ScrollViewer.VerticalScrollMode="Disabled"
>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接