【发布时间】:2015-12-12 01:41:54
【问题描述】:
我必须将从 page1.xaml 的 rest web 服务获得的 id 发送到 page2.xaml 我试过这段代码:
Page1.xaml.cs:
private async void Grid1_Tapped(object sender, TappedRoutedEventArgs e)
{
UriString2 = "URL";
int x= rootObject.posts[0].id;
string uri = string.Format("/Page2.xaml?x={1}",x);
//adding Navigation Statement
this.Frame.Navigate(typeof(Page2), new Uri(uri, UriKind.Relative));
}
Page2.xaml.cs:
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
int xx = Convert.ToInt32(NavigationContext.QueryString["x"]);
}
此代码不起作用,我有一个错误“NavigationContext 在此上下文中不存在”,我想念什么:(
感谢帮助
【问题讨论】:
标签: c# wpf xaml win-universal-app