Upload
yasmine-abdelhady
View
33
Download
3
Embed Size (px)
Citation preview
“Discover Windows Phone” development series
Yasmine Abdelhady
@yasabdelhady
03. Passing Parameters
© Yasmine Abdelhady| MEA DPE Intern
Agenda Passing Parameters while Navigating to another page.
© Yasmine Abdelhady| MEA DPE Intern
Let's say that you want to merge Meals.xaml and Beverages.xamlin the same page, since they do the same functionality but only display different content. You can also merge the two event handlers of the button since they're also similar. Let's start step by step.
© Yasmine Abdelhady| MEA DPE Intern
How to do this? We have multiple pages, and we want to give the user a way to get
between them. Let's build a simple navigation UI that will allow us to do just that.
© Yasmine Abdelhady| MEA DPE Intern
1)Open the application we created together through the previous couple of posts.2) From the Solution Explorer, delete Beverages.xaml and Meals.xaml3) Create a new page by right clicking the project>Add>New Item>Windows Phone Portrait Page and name it Menu.xaml
© Yasmine Abdelhady| MEA DPE Intern
4) In Mainpage.xaml, change the event handler functionof both buttons to button_click, as shown in the picture
© Yasmine Abdelhady| MEA DPE Intern
5) In MainPage.xaml.cs, delete the old two event handler functions, which were button_meals_click and button_beverages_click and add a new function button_click as shown in the picture
© Yasmine Abdelhady| MEA DPE Intern
6) Go to Menu.xaml.cs, where the parameter that was passed to from MainPage.xaml.cs. Add to the OnNavigatedTo, if it is not there add it.
© Yasmine Abdelhady| MEA DPE Intern
Thank you
@yasabdelhady
yasabdelhady.wordpress.com
Facebook.com/yasabdelhady
© Yasmine Abdelhady| MEA DPE Intern