xaml – 如何检测ListView向上或向下滚动
发布时间:2020-12-14 01:47:36 所属栏目:Windows 来源:网络整理
导读:有没有办法检测ListView的ScrollViwer处于滚动模式并停止滚动.在 Windows Phone 8.1 ListView中我们无法获得scrollviewer的参考. 任何人在Windows Phone 8.1 WinRT应用程序中完成它? 加载ListView后,您可以像这样获取ScrollViewer: var sv = (ScrollViewer
有没有办法检测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(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-10 – UWP应用程序从系统上的随机位置访问文件
- winapi – Win32 WM_SETCURSOR,WM_MOUSEMOVE总是在成对?
- 在PowerShell中关闭所有资源管理器Windows
- Mono / XSP上的Microsoft.Owin.Host.SystemWeb
- .NET的SuppressKeypress是如何工作的?
- batch-file – 如何使用通配符文件名作为命令行参数调用Win
- microsoft-graph – Microsoft Graph API下载文件内容返回U
- 在Wix中创建自定义操作以用于静默安装
- windows-server-2003 – 想开始使用瘦客户端
- 如何创建涵盖Windows标题栏的Java Swing应用程序?
推荐文章
站长推荐
- windows-server-2008 – 从Windows Server 2008中
- windows – 创建虚拟文件夹并将它们挂钩到文件系
- WinRT和XAML – 资源文件,但语言不是本地化?
- windows-7 – 无法看到我在telnet中输入的内容
- wpf – Windows 7触摸屏“耸耸肩”
- 如何正确创建一个nim / nimrod windows dll
- flutter从零开始第一篇-环境搭建(Windows)
- Windows Azure SDK返回未知的AccountType:undef
- windows – 是否可以在防火墙后面安装一台机器并
- windows-phone-7 – 在tombstone之后恢复LongLis
热点阅读