在Windows Phone的8.1 ​​XAML与WrapGrid的ListView的奇怪行为 [英] Strange behavior of ListView with WrapGrid in Windows Phone 8.1 XAML

查看:209
本文介绍了在Windows Phone的8.1 ​​XAML与WrapGrid的ListView的奇怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一款Windows Phone 8.1的XAML应用程序一个的ListView NAD WrapGrid 作为其ItemsPanel以显示两个项目列

I have a Windows Phone 8.1 XAML app with a ListView nad WrapGrid as its ItemsPanel to display items in two columns

<ListView x:Name="ListV" ItemClick="ListV_ItemClick" IsItemClickEnabled="True">
        <ListView.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapGrid Orientation="Horizontal" ItemWidth="160" ItemHeight="280" MaximumRowsOrColumns="2" />
            </ItemsPanelTemplate>
        </ListView.ItemsPanel>
        <ListView.ItemTemplate>
            <DataTemplate>
                <Grid Background="Red" Margin="12" Width="100" Height="100"></Grid>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>



页面的缓存模式设置为 NavigationCacheMode.Required

我在列表scoll,单击一个项目,然后导航到另一个屏幕。当我浏览回用的ListView 的页面时,的ListView remebers的scoll位置( NavigationCacheMode.Required ),但被破,当我在项目挖掘,他们只是跳奇怪。

I scoll in the list, tap an item and navigate to another screen. When I navigate back to the page with the ListView, the ListView remebers the scoll position (NavigationCacheMode.Required) but gets "broken", when I tap on items, they just jump strangely.

下面是一个完整的简单的解决方案来重现问题: 。https://dl.dropboxusercontent.com/u/73642/listview.zip

Here is a complete simple solution to reproduce the problem: https://dl.dropboxusercontent.com/u/73642/listview.zip.

下面是该问题的视频:的https://dl.dropboxusercontent.com/u/73642/listview.wmv

Here is a video showing the problem: https://dl.dropboxusercontent.com/u/73642/listview.wmv

任何人都经历过这样?有没有解决这个问题的方法吗?

Anyone else experienced this? Is there a way around this issue?

推荐答案

一个解决办法,我发现是包装在的ListView 的ScrollViewer 。下面是垂直滚动浏览器的样式:

One workaround I've found is to wrap the ListView in a ScrollViewer. Here's a style for vertical scroll viewer:

<Style x:Key="VerticalScrollViewerStyle" TargetType="ScrollViewer">
    <Setter Property="HorizontalScrollBarVisibility" Value="Disabled" />
    <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
    <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled" />
    <Setter Property="ScrollViewer.VerticalScrollMode" Value="Enabled" />
    <Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
</Style>

然后您缠绕的ListView 这样的

<ScrollViewer Style="{StaticResource VerticalScrollViewerStyle}">
    <ListView ...>
        ...
    </ListView>
</ScrollViewer>

这方式的的ListView 内部的ScrollViewer 不使用,这似乎解决您的问题。现在,有可能是与的ListView 依赖于内部的ScrollViewer 中使用的某些功能的一些问题(如:增量加载)。你会测试它,你会看到,如果你所需要的作品。

This way the ListView's internal ScrollViewer is not used, and this seems to solve your problem. Now, there might be some issues with some features of the ListView that depend on the internal ScrollViewer to be used (e.g. incremental loading). You'll test it and you'll see if what you need works.

这篇关于在Windows Phone的8.1 ​​XAML与WrapGrid的ListView的奇怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆