Is it possible to navigate to pivot control page by a button clicked event
Solution 1
If you have for example following definition for the Pivot control:
<controls:Pivot x:Name="SettingsPivot" Title="settings">
<controls:PivotItem x:Name="GeneralSettings" Header="general settings">
<!-- Pivot Item content -->
</controls:PivotItem>
<controls:PivotItem x:Name="ConnectivitySettings" Header="connectivity settings">
<!-- Pivot Item content -->
</controls:PivotItem>
<controls:PivotItem x:Name="OtherSettings" Header="other settings">
<!-- Pivot Item content -->
</controls:PivotItem>
</controls:Pivot>
Then you can go to for example OtherSettings using this code in the button click event handler:
SettingsPivot.SelectedItem = OtherSettings;
Solution 2
do it like this
NavigationService.Navigate(new Uri("/Pages/Page.xaml?PivotMain.SelectedIndex = 0", UriKind.Relative));
SelectedIndex can be whatever depending how many pivot items you have
Solution 3
Here is how you can navigate to another page, it does not matter if it is a pivot page or not:
NavigationService.Navigate(new Uri("/SettingsPivot.xaml", UriKind.Relative));
If you are trying to navigate to another pivotitem then you will need to do the following
int i=1; //This is the index of the pivotitem you would like to navigate to
PivotMenuName.SelectedIndex = i;
Solution 4
Sounds like you want the second piece of code. If your Pivot has 2 items, (say item1, item2), then to navigate to item2 from item1, you would use:
MyPivot.SelectedIndex = IndexOfPageToGoTo;
Check out this quick example that demonstrates it .
http://dl.dropbox.com/u/129101/WindowsPhonePivotApplication1.zip
That said, this isn't recommended if you're using it for a "Wizard" style application. See http://timheuer.com/blog/archive/2010/08/13/windows-phone-panorama-versus-pivot-ux-guidelines.aspx
New developer
Updated on July 26, 2022Comments
-
New developer almost 2 years
I'm trying to create a wp7 pivot control application. On click of a button in the first page, I would like to navigate to another page which is already a pivot page. Is it possible ?
-
New developer about 13 yearsI'm sorry I din get you right. For navigating to the next page, we generally use : NavigationService.Navigate(new Uri("/SettingsPivot.xaml", UriKind.Relative)); However, In case of a Pivot application we have all the details in the same MainPage.xaml. So in that case, how should I navigate?
-
Jari about 13 years@New developer: Please consider accepting this as an answer if it was what you were after, so that this question gets closed in a proper way.
-
dlewin over 12 yearsthis kind of answers are like gold. I have been searching in MSDN, IRC channel, and google and lost my time to finally arrive to this one : great ! (+1)
-
Zia Ur Rahman over 10 yearsThanks Jari, Great help... keep it up.
-
王凯越 Kaiyue Wang over 7 yearsGood one, but what if the button is in a page in one of the pivot items, how can I navigate to a different pivot from within the page? I'm in UWP developing now.