xaml – 如何检测ListView向上或向下滚动

有没有办法检测ListView的ScrollViwer处于滚动模式并停止滚动.在 Windows Phone 8.1 ListView中我们无法获得scrollviewer的参考.

任何人在Windows Phone 8.1 WinRT应用程序中完成它?

加载ListView后,您可以像这样获取ScrollViewer:
var sv = (ScrollViewer)VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(this.ListV,0),0);

编辑

正如Romasz建议的那样,一旦你获得了ScrollViewer,就可以使用它的ViewChanged事件来监视它何时滚动以及何时停止.

此外,这是我用于遍历可视树的通用扩展方法

// The method traverses the visual tree lazily,layer by layer
// and returns the objects of the desired type
public static IEnumerable<T> GetChildrenOfType<T>(this DependencyObject start) where T : class 
{
    var queue = new Queue<DependencyObject>();
    queue.Enqueue(start);

    while (queue.Count > 0) {
        var item = queue.Dequeue();

        var realItem = item as T;
        if (realItem != null) {
             yield return realItem;
        }

        int count = VisualTreeHelper.GetChildrenCount(item);
        for (int i = 0; i < count; i++) {
            queue.Enqueue(VisualTreeHelper.GetChild(item,i));
        }
    }
}

要使用此方法获取ScrollViewer,请执行以下操作:

var sv = yourListView.GetChildrenOfType<ScrollViewer>().First();

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...