1. Fragment
导航页面
private void NavigateWithFragmentButton_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new Uri(“/SecondPage.xaml#HelloWorld”, UriKind.Relative));
}
导航到页面
protected override void OnFragmentNavigation(FragmentNavigationEventArgs e)
{
base.OnFragmentNavigation(e);
MessageBox.Show(“Fragment: “ + e.Fragment);
}
2. QueryString
导航页面
private void NavigateWithQueryButton_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new Uri(“/SecondPage.xaml?CustomerId=1234 & Product=555”,UriKind.Relative));
}
导航到页面
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
foreach (var item in NavigationContext.QueryString)
{
MessageBox.Show(“Query String [“ + item.Key + “] = “ + item.Value);
}
}
3. 用一个全局的Dictionary用来存放页面之间临时传递的参数
注:尽可能降低页面之间的耦合,方便墓碑化