【目标】前一篇文章已经实现了图片的切换,这里需要限制pivot的循环滚动。
【思路】通过手势事件,对第一张,最后一张图片处加以限制
【前台】
在pivot处加上
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener DragDelta="GestureListener_DragDelta_1" DragCompleted="GestureListener_DragCompleted_1" />
</toolkit:GestureService.GestureListener>
【后台】
private void GestureListener_DragCompleted_1(object sender, DragCompletedGestureEventArgs e)
{
if ((this.imagePivot.SelectedIndex == ellipses.Count - && e.HorizontalChange < ) || (this.imagePivot.SelectedIndex == && e.HorizontalChange > ))
{
this.imagePivot.IsLocked = true;
}
} private void GestureListener_DragDelta_1(object sender, DragDeltaGestureEventArgs e)
{
if ((this.imagePivot.SelectedIndex == ellipses.Count - && e.HorizontalChange > ) || (this.imagePivot.SelectedIndex == && e.HorizontalChange < ))
{
this.imagePivot.IsLocked = false;
}
}