当ScrollViewer中已经停止滚动检测 [英] Detect when ScrollViewer has stopped scrolling
问题描述
我有一个 SurfaceListBox
这里面有一个的ScrollViewer
。我有机会到的ScrollViewer
,我希望在滚动结束检测。由于它是一个触摸应用程序,我可以拖动它,现在我检测 PreviewTouchUp
做我想做什么,但是,如果我做一个快速轻扫,喜欢你会做在智能手机上,因为内容的的ScrollViewer
仍然拖着/滚动,在 PreviewTouchUp
并不能反映滚动的结束,而是被触发之前,搜索结果
I have a SurfaceListBox
that inside has a ScrollViewer
. I have access to that ScrollViewer
and I want to detect when the scrolling ends. Since it is a touch app and I can drag it, right now I'm detecting the PreviewTouchUp
to do what I want, however, if I do a fast swipe, like you would do on a smartphone, because the content of the ScrollViewer
is still dragging/scrolling, the PreviewTouchUp
does not reflect the end of the scrolling, but is instead triggered before.
我曾尝试操作
事件和其他几个人同时在的ScrollViewer
和 SurfaceListBox
。我也曾尝试 ScrollViewer.PanningDeceleration
和诚实,我看不出区别。基本上,至今没有运气。搜索结果
I have tried Manipulation
events and several others on both the ScrollViewer
and the SurfaceListBox
. I have also tried ScrollViewer.PanningDeceleration
and honestly, I don't see a difference. Basically, no luck so far.
那么,如何检测滚动的结束,即使在 PreviewTouchUp
在的ScrollViewer
?
So, how can I detect the end of the scrolling, even after the PreviewTouchUp
in a ScrollViewer
?
推荐答案
灿'T你只是处理的 ScrollViewer.ScrollChanged
事件?从所链接的页面,它说,它...
Can't you just handle the ScrollViewer.ScrollChanged
event? From the linked page, it says that it...
时发生。
所以,你可以只启动一个 DispatcherTimer
来等待一段即时每个活动时间内已经提高,例如。当它被滚动。当滚动停止和事件停止的提高,那么勾选
处理程序将被调用,你可以做任何你喜欢它。尝试是这样的:
So you could just start a DispatcherTimer
to wait for a short instant each time the event has been raised, eg. when it is scrolling. When the scrolling stops and the event stops being raised, then the Tick
handler will be called and you can do whatever you like in it. Try something like this:
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 0, 0, 250);
timer.Tick += Timer_Tick;
...
private void ScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (timer.IsEnabled) timer.Stop();
timer.Start();
}
private void Timer_Tick(object sender, EventArgs e)
{
timer.Stop();
// Do what you want now that scrolling has stopped
}
这篇关于当ScrollViewer中已经停止滚动检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!