【问题标题】:How to navigate to different pivot items in WP7如何在 WP7 中导航到不同的数据透视项目
【发布时间】:2012-05-23 18:00:27
【问题描述】:

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

【问题讨论】:

    标签: c# windows-phone-7


    【解决方案1】:

    您可以将查询字符串传递给数据透视页面,然后在加载数据透视页面后,将索引设置为相关页面。作为一个基本示例,您可以像这样处理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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多