I am doing a windows phone application, in which the main screen (first screen) is made a calculation, and the result is displayed on a second screen.
I was able to make the 'connection' between the two screens as follows
On page 1 or main screen:
private void button2_Click(object sender, RoutedEventArgs e)
{
Uri caminho = new Uri("/Paginas/Resolucao.xaml?parametro=" textBlock1.Text, UriKind.Relative);
NavigationService.Navigate(caminho);
}
On page 2 or secondary screen
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string parametroRecebido1 = NavigationContext.QueryString["parametro"];
textBlock2.Text = parametroRecebido1;
}
But with these 'methods' I can only pass a variable (the variable that stays in textBlock1) I saw this link in Option3 that to pass more than one variable would have to be made the following code:
On page 1 or main screen;
private void btnNavigate_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Page1.xaml?parameter1=p1& parameter2=p2",UriKind.Relative));
}
Second screen;
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string parameterValue1 = NavigationContext.QueryString["parameter1"];
string parameterValue2 = NavigationContext.QueryString["parameter2"];
}