2011-07-27 33 views
4

我知道如何在透視頁面內從一個透視圖項目導航到另一個透視項目,但是如果導航是從另一個頁面完全啓動的呢?有沒有一種方法來指定哪個數據透視表項在透視頁面中導航?

UPDATE:

這裏是我使用的解決方案的基礎上,從馬特萊西答案:

從按鈕單擊事件上的MainPage:

private void button_Click(object sender, RoutedEventArgs e) 
     { 
      string parameter = "myPivotItem1"; 
      NavigationService.Navigate(new Uri(string.Format("/MyPivotPage.xaml?parameter={0}", parameter), UriKind.Relative)); 
     } 

推翻的OnNavigatedTo爲支點頁,並提取查詢字符串:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) 
     { 
      base.OnNavigatedTo(e); 
      string newparameter = this.NavigationContext.QueryString["parameter"]; 
      if (newparameter.Equals("myPivotItem1")) 
      { 
       myPivotControl.SelectedItem = myPivotItem1; 
      } 
      else if (newparameter.Equals("myPivotItem2")) 
      { 
       myPivotControl.SelectedItem = myPivotItem2; 
      } 
     } 

回答

1

您可以設置SelectedIndex到你想要的物品的索引。

雖然要小心物品的延遲加載。

更新:
在第一頁上,通過你導航到該頁面的一個指標,其中pivotItem在查詢字符串顯示**。
在包含數據透視表的頁面上的OnNavigatedTo事件中,爲Pivot的Loaded事件創建一個處理程序,並使用該處理程序設置SelectedIndex。

**可以使用其他方法。

+0

我在哪裏以及如何做到這一點? – Marmoy

+0

謝謝你使用術語查詢字符串,發現這個深入的解釋wp7導航和概念:http://www.windowsphonegeek.com/articles/WP7-Navigation-in-depth--Navigation-Framework – Marmoy

+0

你提到,有傳遞您希望導航到的數據透視表的指標的不同方式是指使用隔離存儲,數據庫和其他全局存儲,這將允許您設置整個應用程序可訪問的值? – Marmoy

相關問題