Windows Phone Silverlight中的NavigationService

时间:2015-10-04 12:55:12

标签: c# silverlight windows-phone

我可以使用Btn_Click方法调用NavigationService

private void Com_Click(object sender, RoutedEventArgs e)
{   string test = "Com";
    var x = NavigationService.Navigate(new Uri(@"/PageList.xaml" + "?msg1=" + test, UriKind.Relative));
}

但我不能以这种方式叫同一个服务

public MainPage()
{
    InitializeComponent();
    ...
    Test();
}    
private void Test()
{   string test = "Com";
    var x = NavigationService.Navigate(new Uri(@"/PageList.xaml" +   "?msg1=" + test, UriKind.Relative));
}

1 个答案:

答案 0 :(得分:0)

尝试不使用var x =

  private void Test()
  {  
    string test = "Com";
     NavigationService.Navigate(new Uri(@"/PageList.xaml" +   "?msg1=" + test, UriKind.Relative));
  }