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
– Diego Leite