BackNavigationIf you are used to making apps for Windows Phone prior to the WinRT Universal app projects, navigation was handled quite differently.

One of the large changes is the hardware back button. By default, it navigated backwards through the navigation stack. If you attempt to hit the hardware back button out of the box in a universal app however, it exits the app.

How do we get around this? In Silverlight based apps, there is an OnBackKeyPress method that you might be aware of, but it is not there in WinRT.

The solution is quite simple, but not obvious, because the techniques are different. The HardWareButtons.BackPressed event has to handled in your code.

The key in the HardWareButtonsBackPressed method is to mark the event as being handled, if you do not, it will still navigate away from your app, after it navigates to the previous page.

Leave a Reply
Your email address will not be published.
  • ( will not be published )