14
“Discover Windows Phone” development series Yasmine Abdelhady @yasabdelhady [email protected] 02. Page Navigation © Yasmine Abdelhady| MEA DPE Intern

"Discover windows phone" 02. page navigation

Embed Size (px)

Citation preview

Page 1: "Discover windows phone"   02. page navigation

“Discover Windows Phone” development series

Yasmine Abdelhady

@yasabdelhady

[email protected]

02. Page Navigation

© Yasmine Abdelhady| MEA DPE Intern

Page 2: "Discover windows phone"   02. page navigation

Agenda Simple Page Navigation

© Yasmine Abdelhady| MEA DPE Intern

Page 3: "Discover windows phone"   02. page navigation

Why is it important?

Page Navigation:1. because you don’t want to build your project based on only one page

2. because you can make use that your application will automatically be able to leverage the phone's built-in hardware back button.

© Yasmine Abdelhady| MEA DPE Intern

Page 4: "Discover windows phone"   02. page navigation

Simple Navigation

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"   02. page navigation

1.

we've created a default Windows Phone Application, let's open it.

Open the application from where you saved it last time. (Probably it will be in Documents>Visual Studio 2013>Projects

© Yasmine Abdelhady| MEA DPE Intern

Page 6: "Discover windows phone"   02. page navigation

2.

Right Click on the Project in the Solution Explorer>Add>New Item

© Yasmine Abdelhady| MEA DPE Intern

Page 7: "Discover windows phone"   02. page navigation

3.

(Under Windows Phone on the left pane) Windows Phone Portrait Page. Name it Meals.xaml

© Yasmine Abdelhady| MEA DPE Intern

Page 8: "Discover windows phone"   02. page navigation

4 & 5

4. Change page's title, so we know we're on each page. Look for the XAML Textblock element with Text "page name" to "Meals“5. Repeat step 3 and 4 with page name Beverages.xaml and page name "Beverages".

© Yasmine Abdelhady| MEA DPE Intern

Page 9: "Discover windows phone"   02. page navigation

6.

Go back to MainPage.xaml and also change "page name" to "Main Page".

© Yasmine Abdelhady| MEA DPE Intern

Page 10: "Discover windows phone"   02. page navigation

7.

Add 2 buttons in the MainPage.xaml by dragging the "Button" control from the Toolbox window to the MainPage designer view.

© Yasmine Abdelhady| MEA DPE Intern

Page 11: "Discover windows phone"   02. page navigation

8.

Change the text that appears on each button by going to the Properties windows on the left. Under Common, change Content from "button" to Meals. Do the same to button 2 and change Content to "Beverages". Also change the name of each button from the same properties window as shown. Change names to "button_meals" and "button_beverages".

© Yasmine Abdelhady| MEA DPE Intern

Page 12: "Discover windows phone"   02. page navigation

9.

Add a Click event to the button, that when you click on the button a special event happens, which in our case is to navigate to a specific page. To do this, double click on the button itself in the design view and it will automatically create an event handler and take you to the C# page where you write what happens when the button is clicked. Do the same click to the second button.

Page 13: "Discover windows phone"   02. page navigation

10.

Now is finally time to write the statement of navigation to another page.for button_mealsNavigationService.Navigate( new Uri("/Meals.xaml", UriKind.Relative));And for button_beveragesNavigationService.Navigate( new Uri("/Beverages.xaml", UriKind.Relative));

Page 14: "Discover windows phone"   02. page navigation

Thank you

@yasabdelhady

[email protected]

yasabdelhady.wordpress.com

Facebook.com/yasabdelhady

© Yasmine Abdelhady| MEA DPE Intern