C# 从用户控件导航到页面

C# 从用户控件导航到页面,c#,windows-phone-8,C#,Windows Phone 8,我有一个usercontrol页面,其中包含以下代码 private void StackPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e) { Uri uri = new Uri("/News.xaml", UriKind.Relative); if (uri != (Application.Current.RootVisual as PhoneApplicationFrame).CurrentSourc

我有一个usercontrol页面,其中包含以下代码

private void StackPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
  Uri uri = new Uri("/News.xaml", UriKind.Relative);

  if (uri != (Application.Current.RootVisual as PhoneApplicationFrame).CurrentSource)
  {
    (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(uri);
  }
}

但是如果我导航到该页面,它会给出一个导航错误。但如果它导航到另一个页面,它确实可以工作。有什么问题吗?

最好使用以下导航:

private void StackPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
   Uri uri = new Uri("/News.xaml", UriKind.Relative);
   if (uri != (Application.Current.RootVisual as PhoneApplicationFrame).CurrentSource)
   {
       NavigationService.navigate(uri);
   }
}

并确保News.xaml存在并且位于解决方案的根目录中。

处理异常并告诉错误消息是什么?