防止在全景项目或枢轴项目的最后一项上滚动wp7 c#

我有n个枢轴项。 如何停止从最后一个项目滚动到第一个项目。 任何帮助将不胜感激。

我不确定这是否有效,因此正如Ulugbek Umirov在评论中所说的那样 – 它取决于操作系统版本。 我现在没有模拟器尝试,但你可能会尝试这样做:

public MainPage() { InitializeComponent(); myPivot.IsHitTestVisible = false; // disable your Pivot Touch.FrameReported += Touch_FrameReported; TouchPanel.EnabledGestures = GestureType.HorizontalDrag; } TouchPoint first; private const int detectRightGesture = 20; private void Touch_FrameReported(object sender, TouchFrameEventArgs e) { TouchPoint mainTouch = e.GetPrimaryTouchPoint(this); if (mainTouch.Action == TouchAction.Down) first = mainTouch; else if (mainTouch.Action == TouchAction.Up && TouchPanel.IsGestureAvailable) { if (mainTouch.Position.X - first.Position.X < -detectRightGesture) { if (myPivot.SelectedIndex < myPivot.Items.Count - 1) myPivot.SelectedIndex++; } else if (mainTouch.Position.X - first.Position.X > detectRightGesture) { if (myPivot.SelectedIndex > 0) myPivot.SelectedIndex--; } } } 

根据MSDN -应该可以从WP7.1获得TouchPanel ,并且应该在WP7.0上提供Touch.FrameReported Event 。 因此它有可能发挥作用。

您必须添加对Microsoft.Xna.Framework.Input.Touch程序集的引用。

我还添加了detectRightGesture这样Pivot就不会打开小垂直拖动,如果需要的话,这是一个测试问题。