简体   繁体   中英

NavigationService in Windows Phone Silverlight

I can call NavigationService with a Btn_Click method

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

But I can't call the same Service on this way

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

Try without var x = :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM