I am trying to work out how to transfer string value from one windows phone app page to the next, following this article but I get an error that reads "The name 'NavigationService' does not exist in the current context".
There is a textbox and a button on page1. There is only a TEXTBLOCK on page 2. I wish to enter a string in the textbox of page 1, and when the button is clicked, the page 2 shows up with the text from the textbox (of page 1) in the textblock of page 2.
For the button click even in page 1, I entered this:
private void Button_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Page2.xaml?msg=" + Texbox_page1.Text, UriKind.Relative));
}
In the OnNavigatedTo method, in page 2, I entered
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string msg = "";
if (NavigationContext.QueryString.TryGetValue("msg", out msg))
{
Textblock_nickname_display.Text = msg;
}
}
What am I missing? If there is n easier way to do this, please share!
I've spend almost 4 hours trying to figure this out, watching YouTube videos and what not!
Thanks in advance!