How to detect a Pivot item is selected in Windows Phone 7

♀尐吖头ヾ 提交于 2020-01-23 04:37:08

问题


I am implementing the Pivot control in Windows Phone 7.

I want to know which Pivot item is selected and active after the user does a swipe gesture.

How to detect the swipe gesture event related to Pivot control?

Which delegate method should I use ?


回答1:


SelectionChanged is the event to wire up to for detecting Pivot item changes.

As kP suggests, SelectedIndex/SelectedItem are the properties you can access to see which item is currently selected.

Here's an example event handler to show the SelectedIndex each time it changes.

    private void thisPivot_SelectionChanged(object sender, SelectionChangedEventArgs e) {
        System.Diagnostics.Debug.WriteLine(thisPivot.SelectedIndex);
    }



回答2:


You could use the Pivot.SelectedItem method which is a getter and setter. This will allow you to return the current PivotItem the user is on. Alternatively, you could use the Pivot.SelectedIndex method if you just want to access the indexes of each PivotItem.




回答3:


If you want to perform an action once the PivotItem has actually finished loading entirely and transition animation sequence is complete, take a look at the LoadedPivotItem event.



来源:https://stackoverflow.com/questions/4059425/how-to-detect-a-pivot-item-is-selected-in-windows-phone-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!