【问题标题】:WrapGrid horizontal scroll Windows 8WrapGrid 水平滚动 Windows 8
【发布时间】:2013-10-11 09:20:44
【问题描述】:

我有下一个用于主网格的 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>

它垂直堆叠所有东西:

我做错了什么?

【问题讨论】:

    标签: xaml listview windows-runtime horizontal-scrolling


    【解决方案1】:

    找到了解决办法。不需要 ScrollViewer。

    只需要用 GridView 替换 ListView,因为 ListView 不是为水平滚动而设计的。

    【讨论】:

    • 实际上,您可以将 ListView 的行为更改为像 GridView 一样。它主要与自定义 ItemsPanelTemplate 有关。他们甚至使用相同的资源进行样式设置。
    【解决方案2】:

    你可以试试这个

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

    【讨论】:

      猜你喜欢
      • 2014-03-30
      • 1970-01-01
      • 2013-07-14
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多