导航Windows Phone应用程序

本文关键字:应用程序 Phone Windows 导航 | 更新日期: 2023-09-27 17:54:36

我想为我的windows phone应用程序从一个页面导航到另一个页面,但问题是,如果我使用这种类型的代码:

private void hyperlinkButton1_Click(object sender, RoutedEventArgs e) 
{ 
   NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative)); 
}

调试器说NavigationService在上下文中不可用

我该怎么办?

导航Windows Phone应用程序

NavigationService不存在,因为它只在Windows Phone Silverlight应用中使用。

使用Frame.Navigate ():

Frame.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative));

如果您使用项目模板Windows Phone 8.0Windows Phone 8.0(Sliverlight)

然后尝试低于1:

NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative));

如果你使用的是Windows phone 8.1,那么:

Frame.Navigate(typeof(SecondPage));

Frame.Navigate(typeof(SecondPage), param);