Handling the Back Button in a Windows Phone 8.1 app

If you are developing an app using the Universal app template then you may have noticed that the app terminates on pressing the hardware back button.
Lets navigate from Page1.xaml to Page2.xaml by using a button with the click event code:


When we are on Page2, and the hardware back button is used, the app closes without an exception or anything. It just returns to the start screen. This is new to Windows Phone 8.1. If you create a new Hub Universal App using a VS2013 template, you’ll notice a class in Common folder called a NavigationHelper.
This NavigationHelper gives you a hint how to properly react to back button press. So, if you don’t want to use the NavigationHelper, here’s how to get the old behavior back:

You can also do it on app level, to avoid having to do it on every page:

if you wish to disable the back button in your application you can view the following post
How to disable Hardware Back button in Windows Phone App

Vivek Maskara

I am pursuing BTech in Software Engineering from Delhi Technological University. I develop apps, create websites and blog about my app 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