如何导航到不同的WP7项目支点 [英] How to navigate to different pivot items in WP7
问题描述
我有,我有3个按钮的全景页面。我添加了一个pivotpage到具有3支点项目在同一个项目。当我在全景页它应该转到枢轴页的第一个支点项目点击按钮1,当我在全景页它应该转到枢轴页第二枢项目点击按钮2。我怎样才能做到这一点的导航?请让我知道。
I have a panorama page in which I have 3 buttons. I have added a pivotpage to the same project which has 3 pivot items. When I click Button 1 in panorama page it should goto the first pivot item in pivot page and when I click button 2 in panorama page it should goto the second pivot item in pivot page. How can I achieve this navigation? Please let me know.
推荐答案
您可以通过查询字符串枢轴页面,然后,一旦支点被加载,设置索引到相关的网页。作为一个基本的例子,你可以处理按钮2
是这样的:
You could pass a querystring to the pivot page and then, once the pivot is loaded, set the index to the relevant page. As a basic example, you can handle button 2
like this:
NavigationService.Navigate(new Uri("/myPivotPage.xaml?id=2", UriKind.Relative));
然后在你的支点页面的加载
事件,您可以设置跳转到这样的指标:
Then in your pivot page's Loaded
event, you can set the jump to the index like this:
string pivotIndex = "";
if(NavigationContext.QueryString.TryGetValue("id", out pivotIndex))
{
//-1 because the Pivot is 0-indexed, so pivot item 2 has an index of 1
myPivot.SelectedIndex = Convert.ToInt32(pivotIndex) - 1;
}
这篇关于如何导航到不同的WP7项目支点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!