Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 ?

like image 681
user403015 Avatar asked Oct 30 '10 15:10

user403015


2 Answers

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);
    }
like image 61
Mick N Avatar answered Nov 12 '22 05:11

Mick N


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.

like image 38
keyboardP Avatar answered Nov 12 '22 03:11

keyboardP