防止滚动WP7上的C#全景项或枢纽项目的最后一个项目 [英] Prevent scrolling on last item of panorama item or pivot item wp7 c#
问题描述
我的支点项目n个。如何阻止最后滚动到第一个项目。任何帮助将不胜感激。
I have n number of pivot items . How to stop scrolling from last to first item. Any help will be greatly appreciated.
推荐答案
我不知道这会的工作,因此作为乌卢格别克Umirov注释中说 - 它是依赖于操作系统的版本。我没有模拟器现在就试试,但你可以尝试这样做是这样的:
I'm not sure if that would work, hence as Ulugbek Umirov said in comments - it is dependant on OS version. I don't have emulator right now to try, but you may try to do it like this:
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 - 的TouchPanel 应该可以从WP7.1和的 Touch.FrameReported事件应该可以在WP7.0。所以有机会的话,它会正常工作。
According to MSDN - TouchPanel should be available from WP7.1 and Touch.FrameReported Event should be available on WP7.0. Therefore there is a chance that it will work.
您必须添加引用 Microsoft.Xna.Framework.Input.Touch
组装。
我还添加了 detectRightGesture
,这样枢轴不小的垂直切换拖动,它的测试,如果将需要的事项。
I've also added detectRightGesture
so that Pivot won't be switched on small vertical drags, it's a matter of test if that will be needed.
这篇关于防止滚动WP7上的C#全景项或枢纽项目的最后一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!