I have come across a few instances where its desireable to navigate to a certain pivot item rather than landing on default and then finding your way around.
This is very easy. I tend to define some mechanism e.g. an enum for each pivot item. I create a static property (or you can choose whatever data passing mechanism you prefer). I set the property and navigate to pivot page and navigate to correct item.
Here’s how i do it. Itercept the OnNavigatedTo of the Pivot page and set the correct item as selected.
public enum PivotDef { One, Two, Three, Four, } public static PivotDef SelectedPivot; protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { switch (SelectedPivot) { case PivotDef.One: this.pvtControl.SelectedItem = this.pvt1; break; case PivotDef.Two: this.pvtControl.SelectedItem = this.pvt2; break; case PivotDef.Three: this.pvtControl.SelectedItem = this.pvt3; break; case PivotDef.Four: this.pvtControl.SelectedItem = this.pvt4; break; } base.OnNavigatedTo(e); }
sample project is available from http://wp7pivottest.codeplex.com
Advertisements
Pingback: Can in I navigate to pivot item from another xaml page in windows phone 7? - Popular Windows Phone Questions