曲面列表框滚动停止事件。 [英] Surface listbox scroll stop event.

查看:78
本文介绍了曲面列表框滚动停止事件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用包含大约50个项目的surfacelistbox。现在,当用户滚动列表框时,我想要捕获一个事件,该事件告诉我列表框不再滚动,即用户要么停止移动列表框,要么暂时停止滚动而不提升从表面接触
。用户可能仍然在表面上有手/手指但是列表框没有滚动。

I am using surfacelistbox which contains some 50 items. Now when user scrolls the listbox I want to trap an event which tells me that listbox is no longer scrolled i.e. user either stops moving the listbox or temporarily stops scrolls without lifting contact from the surface. The user might still have hand/finger on the surface but the listbox is not being scrolled.

是否有类似的事件?

推荐答案

嗨Kavitesh!

Hi Kavitesh!

不,没有这样的事件。它很容易实现。

No, there's no such event. It's easy to implement though.


  1. 从SurfaceListBox的控件模板中解析SurfaceScrollViewer
  2. 当SurfaceScrollViewer.IsAnyContactCaptured 切换为  True(a用户开始交互):连接到SurfaceScrollViewer.ScrollChanged事件并启动DispatcherTimer。设置一个字段(Horizo​​ntalScrollVelocity,VerticalScrollVelocity)=(0,0)
  3. 当您获得ScrollChanged事件时,使用(Horizo​​ntalScrollChange,VerticalScrollChange)中的(Horizo​​ntalScrollChange,VerticalScrollChange)累积一个字段(Horizo​​ntalScrollDelta,VerticalScrollDelta)事件args
  4. 在DispatcherTimer tick事件上; calculate(Horizo​​ntalScrollVelocity,VerticalScrollVelocity)=(Horizo​​ntalScrollDelta,VerticalScrollDelta)/ dt,其中dt是上次更新速度字段时的时间跨度
  5. 当SurfaceScrollViewer.IsAnyContactCaptured切换为False时(用户停止交互):停止DispatcherTimer并取消挂起SurfaceScrollViewer.ScrollChanged事件。设置(Horizo​​ntalScrollVelocity,VerticalScrollVelocity)=(0,0)和(Horizo​​ntalScrollDelta,VerticalScrollDelta)=(0,0)

现在,您可以使用(Horizo​​ntalScrollVelocity ,VerticalScrollVelocity)实现所需的行为。

Now, you can use (HorizontalScrollVelocity,VerticalScrollVelocity) to implement the desired behavior.

祝你好运!

/ Sebastian

/Sebastian


这篇关于曲面列表框滚动停止事件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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