0

I'm developing a little app for Windows Phone 8 that has 2 pages (1 is of course the main page).

When page2 is reached I want to check if this page has been reached by pressing the back button on the phone. I want to do something like this:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    if (backButton.isPressed()) {
        // this page has been reached by pressing the back button on the phone
    } else {
        // this page has been reached by NavigationService.Navigate()
    }
}

Is there a native API to do that?

HBv6
  • 3,487
  • 4
  • 30
  • 43
  • 1
    Be aware that the back button must exit the app on main page or your app won't be certified. So you cannot navigate from main page to page 2 via the back button. – xmashallax Feb 28 '14 at 09:02

1 Answers1

3

Is this what you need?

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    if (e.NavigationMode == NavigationMode.Back)
    {
        ...
    }
}
Igor Ralic
  • 14,975
  • 4
  • 43
  • 51