检测滚动到ScrollViewer的边缘

时间:2014-04-12 15:09:21

标签: xaml windows-store-apps scrollviewer

我只是想知道是否有可能,以及如何检测ScrollViewer中的元素是否已被拖过查看器的边缘。

例如,通过拖动超出允许范围的图像,图像会自动定位在ScrollViewer中,表示至少后端知道图像/滚动已被拖过其边界。我想要做的是还检测何时越过边界然后执行操作,例如将用户活动视为滑动并将显示的项目更改为其他内容。

XAML插图

<ScrollViewer x:Name="detailImageScroll" ZoomMode="Enabled">
    <Image x:Name="detailImage" Visibility="Collapsed" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</ScrollViewer>

C#伪代码

SomeScrollManipulationEvent()
{
  if detailImage.left < detailImageScroll.left
    GoToPreviousImage()
  else if detailImage.right > detailImageScroll.right
    GoToNextImage()
}

到目前为止,我想到的是在ScrollViewers及其图像中无法进行操作,至少在不失去ScrollViewer功能的情况下,例如,缩放和平移。

我是否有可能实施建议的功能?如果是这样,怎么样?

谢谢!

1 个答案:

答案 0 :(得分:0)

它实际上内置于平台中。查看HorizontalSnapPointsTypeHorizontalSnapPointsAlignment属性。

相关问题