Reputation: 2771
I have a pivot control with pivot items on windows phone 8.1. I know how to get the current pivot item by the method SelectedIndex but I need to know on which pivot item I was before the current one.
I've heard about Gesture caching or ManipulationCompleted? I need to know which direction was used to slide on the current pivot item? Does somebody know how to achieve that?
Upvotes: 0
Views: 204
Reputation: 29792
If you need to know the previous index, you can take advantage of SelectionChanged event. For example like this:
// somewhere in constructor
MyPivot.SelectionChanged += MyPivot_SelectionChanged;
int previousIndex;
private void MyPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
previousIndex = MyPivot.Items.IndexOf(e.RemovedItems.FirstOrDefault());
Debug.WriteLine("Previous index: {0}", previousIndex);
}
If you have more items in your Pivot than two, then this method will also allow you to identify the direction of the swipe gesture.
Upvotes: 2