Is it possible to navigate to pivot control page b

2020-02-24 04:16发布

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 ?

6条回答
看我几分像从前
2楼-- · 2020-02-24 04:44

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

查看更多
在下西门庆
3楼-- · 2020-02-24 04:47

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;
查看更多
甜甜的少女心
4楼-- · 2020-02-24 04:53

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

查看更多
啃猪蹄的小仙女
5楼-- · 2020-02-24 04:54

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;
查看更多
我命由我不由天
6楼-- · 2020-02-24 04:58
NavigationService.Navigate(new Uri("MainPage.xaml?PivotMain.SelectedIndex = 0", UriKind.Relative));

index goes 0-1-2-3 ... write which one you want to navigate.

查看更多
冷血范
7楼-- · 2020-02-24 05:06

If you have dynamically create pivot items, you can use this easy code:

// This find object named as customName
object pvtItm = pivotName.FindName("customName");

// If this object has type of PivotItem, navigate to it
if (pvtItm is PivotItem)
{
    pivotName.SelectedItem = pvtItm;
}
查看更多
登录 后发表回答