Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass a parameter in a button and get value in the code behind to redirect to another page based on the value of parameter in windows phone 7?

I am thinking if the windows phone 7 button event is similar to ASP.NET development with C#, something like in the button, I set value to commandparameter in the XAML, and in the code behind, I get the commandparameter and redirect the page.

I haven't found any good examples for button event handling, any suggestions?

Thank you.

like image 304
Xiao Han Avatar asked Dec 01 '22 00:12

Xiao Han


1 Answers

For the xaml:

<Button Tag="pageAddress" Click="Button_Click" />

And then on the code-behind:

private void Button_Click(object sender, RoutedEventArgs e)
{
     Button _button = (Button)sender;
     NavigationService.Navigate(new System.Uri(_button.Tag.ToString()));
}
like image 124
Teemu Tapanila Avatar answered Dec 05 '22 00:12

Teemu Tapanila