How to stop pivot looping

前端 未结 6 1902
礼貌的吻别
礼貌的吻别 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:08

    If you absolutely want to keep the Pivot from looping, here is a quick and dirty hack:

     int previousSelectedIndex = 0;
    
        public PageWithPivot()
        {
            InitializeComponent();
            pivot.SelectionChanged += new SelectionChangedEventHandler(pivot_SelectionChanged); 
        }
    
    
        private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
    
            if (pivot.SelectedIndex == 0 && previousSelectedIndex == )
                pivot.SelectedIndex = ;
            previousSelectedIndex = pivot.SelectedIndex;
        }
    

    This causes your PivotControl to jump back to the last pivotItem. Not very pretty but works.

提交回复
热议问题