Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
How to pass strings between pages on Windows Phone
- How to perform page navigation on Windows Phone (Dev Center)
- NavigationService Class (Dev Center)
- Frame, page, and navigation features in Windows Phone (Dev Center)
Use the Navigate() method of NavigationService to navigate between pages in a Windows Phone app and pass string parameters.
Note: Page navigation is fully covered in How to perform page navigation on Windows Phone (Dev Center). This is a very brief overview of only one aspect.
NavigationService.Navigate(Uri) takes a Uri parameter, which can itself be formatted with string values/parameters. These values can be extracted from the NavigationContext in the receiving page.
Consider a simple app with 2 pages "page1", "page2".
To send a message (on click of submit button on "page1"):
private void submit_click(Object sender, RoutedEventArgs e)
NavigationService.Navigate(new Uri("/Page2.xaml?msg="+ txtName.text, UriKind.Relative) );
To receive the parameter in page 2 we override onNavigatedTo(); the parameters can be retrieved using NavigationContext.QueryString.TryGetValue():
protected override void onNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
string name = msg;