我创建水平滑动会在下一个和上一个项目之间移动。我有三个图像,但问题是当我轻弹一次时它直接转到第三个图像,所以剩下第二个图像。
参考我的 C# 代码如下:
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="OnFlick"/>
</toolkit:GestureService.GestureListener>
private void OnFlick(object sender, FlickGestureEventArgs e)
{
try
{
double ScreenWidth = ScrollGrid.Width;
// User flicked towards left
if (e.HorizontalVelocity < 0)
{
//Load Next Page
double nextPage = (ScrollActivePage + 1) * ScreenWidth;
if (nextPage - ScrollGrid.ScrollableWidth <= ScreenWidth)
{
ScrollGrid.ScrollToHorizontalOffset(nextPage);
ScrollActivePage++;
}
else
{
ScrollGrid.ScrollToHorizontalOffset(ScrollGrid.ScrollableWidth);
}
}
// User flicked towards right
if (e.HorizontalVelocity > 0)
{
//Load Previous Page;
ScrollActivePage = (ScrollActivePage > 0) ? ScrollActivePage - 1 : 0;
ScrollGrid.ScrollToHorizontalOffset(ScrollActivePage * ScrollGrid.Width);
}
}