How to stop pivot looping

前端 未结 6 1867
礼貌的吻别
礼貌的吻别 2021-01-11 22:34

I want to create a wizard control from the pivot control. To achieve this I need to stop the pivot looping. I want to stop the pivot control moving forward from the last ite

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-11 23:22

    It's just an alternative solution I've posted here - you can try to make use of XNA framework TouchPanel and Touch.FrameReported Event:

    using Microsoft.Xna.Framework.Input;
    
    public MainPage()
    {
       InitializeComponent();
       myPivot.IsHitTestVisible = false; // disable your Pivot
       Touch.FrameReported += Touch_FrameReported;
       TouchPanel.EnabledGestures = GestureType.HorizontalDrag; 
    }
    
    TouchPoint first;
    
    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)
            {
                if (myPivot.SelectedIndex < myPivot.Items.Count - 1)
                    myPivot.SelectedIndex++;
            }
            else if (mainTouch.Position.X > first.Position.X)
            {
                if (myPivot.SelectedIndex > 0)
                    myPivot.SelectedIndex--;
            }
        }
    }
    

    Thought it would probably work from WP7.1 as TouchPanel is available from that version of the OS.

提交回复
热议问题