0

Hello I am very new to Silverlight and I want to pass value from one Xaml page to another Xaml page in Silverlight. I got some solution for that as

protected void btn_click(object sender, RoutedEventArgs e)
{ 
    NavigationService.Navigate(new Uri("/Page1.xaml?key1"=txtname.Text, UriKind.Relative));
}

but I am finding an error in it as

An object reference is required for the non-static field, method, property System.Windows.Navigation.NavigationService.Navigate(System.Uri)'

Nkosi
  • 235,767
  • 35
  • 427
  • 472
Ashish
  • 107
  • 1
  • 3
  • 18
  • Try this link its helpful for you http://stackoverflow.com/questions/12444816/how-to-pass-values-parameters-between-xaml-pages – Wenson May 11 '16 at 08:52
  • i am getting an error as: An object reference is required for the non-static field, method, property 'System.Windows.Navigation.NavigationService.Navigate(System.Uri)' ,so the solution is not mentioned in your link – Ashish May 11 '16 at 08:59

1 Answers1

0

Syntax issue. unless that is a typo

protected void btn_click(object sender, RoutedEventArgs e)
{ 
    NavigationService.Navigate(new Uri("/Page1.xaml?key1"=txtname.Text, UriKind.Relative));
}

should change to...

protected void btn_click(object sender, RoutedEventArgs e)
{ 
    NavigationService.Navigate(new Uri("/Page1.xaml?key1="+txtname.Text, UriKind.Relative));
}

Note the change from

"/Page1.xaml?key1"=txtname.Text

to

"/Page1.xaml?key1="+txtname.Text

Nkosi
  • 235,767
  • 35
  • 427
  • 472