我有一个全景页面,其中有 3 个按钮。我已将一个数据透视页添加到具有 3 个数据透视项的同一个项目中。当我单击全景页面中的按钮 1 时,它应该转到数据透视页面中的第一个数据透视项,当我单击全景页面中的按钮 2 时,它应该跳转到数据透视页面中的第二个数据透视项。我怎样才能实现这个导航?请告诉我。

最佳答案

您可以将查询字符串传递给数据透视页面,然后在数据透视加载后,将索引设置为相关页面。作为一个基本示例,您可以像这样处理 button 2:

NavigationService.Navigate(new Uri("/myPivotPage.xaml?id=2", UriKind.Relative));

然后在您的数据透视页面的 Loaded 事件中,您可以像这样设置跳转到索引:
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;
}

关于c# - 如何导航到 WP7 中的不同数据透视项,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9284334/

10-14 16:57