Navigation in Windows Phone 8 and 8.1

In this post we will discuss how to navigate between different pages in Windows Phone 8.1 and Windows Phone 8 apps.

Silverlight

To navigate to another page in a WP Silverlight app, using the following code.
To pass information between pages, save an object in a state like so,

On the navigated page in the constructor, use the following code to retrieve the object.
To view the pages in the back stack, use the following code.

To remove the previous page from the stack, which is useful after a user has logged in & you don’t want them going back to the login page. Use the following method.
It’s best to use the above method in the OnNavigatedTo method in the page code behind.

WinRT

To navigate to another page in a WP WinRT app, using the following code.

To pass information, pass the object as a parameter.
In the navigated page code behind, in the OnNavigatedTo method use the following code to retrieve the object.

To go back, use this simple method,
To remove the previous page from the stack, which is useful after a user has logged in & you don’t want them going back to the login page. Use the following method.

It’s best to use the above method in the OnNavigatedTo method in the page code behind.

Download Navigation in Silverlight

Download Navigation in WinRT

LioneL Chetty

Microsoft Student Partner at the Durban University of Technology. I privately build Windows Phone applications & blog about my learning experiences.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close