How to Pass data between Pages in Windows Phone ?

The NavigationContext provides the QueryString collection which can be used in the destination page to get the data from the URL .

To Send the Data to the different form , the source page has to pass the parameters via URL

like Page2.xaml?name=senthil .

You can send multiple parameters with the help of the ampersand symbol like below


The Sample Program used for demonstration includes 2 pages where page1.xaml is the source and page2.xaml is the destination page

The Page1 has a textbox and a Button . On the button click event , the Navigate method of the NavigationService along with the parameter .

private void button1_Click(object sender, RoutedEventArgs e)
     string urlWIthData = string.Format("/Page2.xaml?name={0}", txtName.Text);
     this.NavigationService.Navigate(new Uri(urlWIthData, UriKind.Relative));

In the Page2.xaml Page Loaded event , the parameter passed from the Page 1 is retreived .

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
     lblPage1Data.Text = this.NavigationContext.QueryString["name"].ToString();

When i attemped to retreive the parameter in the InitializeComponent() , i got the below error .


If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.


  1. How to Pass data between Pages in Windows Phone ? | ProgramInDotnet August 1, 2011 Reply
  2. Yury February 6, 2012 Reply
  3. Shahid March 26, 2012 Reply

Leave a Reply


Interesting BlogPosts to read

Download - Pokemon Go for for Windows 10 (Third Party app)
Pokemon Go is one of the popular AR games for android and iOS devices and now , the game is made ava...
Open Wordpad from command line in Windows
You can use the command "Write" from command line in Windows to open the WordPad application.D:\>...
Popular cross-platform (android and iOS) to-do list app
In this blog post, we will cover some of the popular to-do list app that is available on different p...