NavigationService in Windows Phone Silverlight

本文关键字:Silverlight Phone Windows in NavigationService | 更新日期: 2023-09-27 18:15:50

我可以用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));
}

NavigationService in Windows Phone Silverlight

Try without var x =:

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