获取 Windows Phone 上 ScrollViewer 的滚动事件
问题: 在 Windows Phone 上获取 ScrollViewer 的滚动事件
我有一个像这样的滚动查看器:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer x:Name="MyScroller">
<StackPanel>
<!-- ... -->
</StackPanel>
</ScrollViewer>
</Grid>
我需要 MyScroller 发生滚动时的事件:
// MyScroller.Scroll += // <-- "Scroll" event does not exist on ScrollViewer
MyScroller.MouseWheel += MyScroller_MouseWheel; // Does not fire on scroll
MyScroller.ManipulationDelta += MyScroller_ManipulationDelta; // Fires for pinch-zoom only
Question:
Get scroll event for ScrollViewer on Windows Phone
I have a scrollviewer like so:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer x:Name="MyScroller">
<StackPanel>
<!-- ... -->
</StackPanel>
</ScrollViewer>
</Grid>
I need the event for when the scrolling occurs for MyScroller:
// MyScroller.Scroll += // <-- "Scroll" event does not exist on ScrollViewer
MyScroller.MouseWheel += MyScroller_MouseWheel; // Does not fire on scroll
MyScroller.ManipulationDelta += MyScroller_ManipulationDelta; // Fires for pinch-zoom only
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
MouseMove 在 ScrollViewer 滚动时触发:
它不直观,因为它被命名为“鼠标”事件,并且手机上没有鼠标。但是,触摸点确实相对于 ScrollViewer 容器移动,这就是它处理滚动的方式。
MouseMove fires when ScrollViewer is scrolled:
It isn't intuitive, since it is named as a "mouse" event and there is no mouse on the phone. The touch point does move, however, relative to the ScrollViewer container, which is how it can handle scrolling.
事情没那么简单,但是这个问题中写了一些滚动检测机制:
WP7 自动增长ListBox 到达最后一项
基本上看一下OnListVerticalOffsetChanged 的调用和使用方式。
It's not that simple, but there's a few scroll detection mechanisms written in this question:
WP7 Auto Grow ListBox upon reaching the last item
Basically take a look at the way OnListVerticalOffsetChanged is called and used.
使用 Mango,您可以观察“ScrollStates”视觉状态的变化,如以下所述 示例项目。
With Mango, you can watch for the "ScrollStates" visual state to change as described in this sample project.