Use variables from one main screen on a second screen

1

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

    
asked by anonymous 28.02.2015 / 02:00

1 answer

0

I do not know if it's the right way or the easiest way, but you can pass the variable as the link parameter used to navigate to page 2 and set page 2 to 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); 
       } 
 }
    
28.02.2015 / 02:54