Use variables from a main screen on a second screen

Asked

Viewed 73 times

1

I’m making an application on windows phone, in which I have the main screen ( first screen ), and on this screen is made a calculation, where the result will be displayed on a second screen. My question is as follows; How do I display/use these variables from the main screen on that second screen ? Thanks

1 answer

0


I don’t know if it’s the right way or the easiest way, but you can pass the variable as a parameter of the link used to navigate to page 2 and set in page 2 an Onnavigatedto method to receive this parameter, see.

On page 1:

private void btnNavegar_Click(object sender, RoutedEventArgs e) 
{ 
Uri caminho = new Uri("/Pagina2.xaml?parametro=" + txtParametro.Text,UriKind.RelativeOrAbsolute); 
NavigationService.Navigate(caminho); 
}

On page 2:

protected override void OnNavigatedTo(NavigationEventArgs e) 
{ 
  base.OnNavigatedTo(e); 
  string parametroRecebido; 
  if (NavigationContext.QueryString.TryGetValue("parametro", out parametroRecebido))
       { 
          MessageBox.Show("O paramêtro recebido foi : " + parametroRecebido); 
       } 
 }
  • It worked here , worth :DDD, but if I want to pass more than one parameter, how do I do ? worth dnv:DD

Browser other questions tagged

You are not signed in. Login or sign up in order to post.