9
“Discover Windows Phone” development series Yasmine Abdelhady @yasabdelhady [email protected] 03. Passing Parameters © Yasmine Abdelhady| MEA DPE Intern

"Discover windows phone" 03.passing parameters

Embed Size (px)

Citation preview

Page 1: "Discover windows phone" 03.passing parameters

“Discover Windows Phone” development series

Yasmine Abdelhady

@yasabdelhady

[email protected]

03. Passing Parameters

© Yasmine Abdelhady| MEA DPE Intern

Page 2: "Discover windows phone" 03.passing parameters

Agenda Passing Parameters while Navigating to another page.

© Yasmine Abdelhady| MEA DPE Intern

Page 3: "Discover windows phone" 03.passing parameters

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

Page 4: "Discover windows phone" 03.passing parameters

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

Page 5: "Discover windows phone" 03.passing parameters

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

Page 6: "Discover windows phone" 03.passing parameters

4) In Mainpage.xaml, change the event handler functionof both buttons to button_click, as shown in the picture

© Yasmine Abdelhady| MEA DPE Intern

Page 7: "Discover windows phone" 03.passing parameters

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

Page 8: "Discover windows phone" 03.passing parameters

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

Page 9: "Discover windows phone" 03.passing parameters

Thank you

@yasabdelhady

[email protected]

yasabdelhady.wordpress.com

Facebook.com/yasabdelhady

© Yasmine Abdelhady| MEA DPE Intern