To save the state of the Pivot you should be using the State
property of the page in the OnNavigatedTo
and OnNavigatedFrom
methods.
Here is a basic example:-
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if (State.ContainsKey("pivotIndex"))
myPivot.SelectedIndex = (int)State["pivotIndex"];
}
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
State["pivotIndex"] = myPivot.SelectedIndex;
}
Note that the Windows Phone will handle the persisting of this state in the case where your application gets tombstoned. This approach also enables your page to navigate to elsewhere in the app and on navigation back your pivot state is restored.