Hardware Back Button

,

The hardware Back button is analogous to the Back button on a web browser. However, when the user presses the Back button, past the first page of a phone app, the app is closed. This is in contrast to the phone’s hardware start button, which merely causes an app to be deactivated.


Note

The hardware Back button should not be used for application-specific behavior. It is only for navigation, and if used otherwise, may cause your app to fail Windows Phone Marketplace certification.


To determine whether navigation is occurring because the hardware Back button was pressed or the navigation was initiated by a call to NavigationService.GoBack, use the NavigatingEventArgs.NavigationMode property as shown:

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
    base.OnNavigatedFrom(e);

    if (e.NavigationMode == NavigationMode.Back)
    {
        // Back button pressed.
    }
}

The back key button can also be canceled by overriding the PhoneApplicationPage.OnBackKeyPress, as shown in the following excerpt:

protected override void OnBackKeyPress(CancelEventArgs e)
{
    base.OnBackKeyPress(e);

    e.Cancel = true;
}

OnBackKeyPress is called before OnNavigatedFrom, and if the Back button is canceled, OnNavigatedFrom is not called at all.


Note

The Windows Phone Marketplace certification requirements forbid canceling the Back button in most cases. To maintain a consistent user experience, the Back button must only be used for backward navigation in the application. The following four certification requirements relate to use of the Back button:

Image Pressing the Back button must return the application to the previous page or return to any previous page within the back stack.

Image Pressing the Back button from the first screen of an application must close the application.

Image If the current page displays a context menu or a dialog, the pressing of the Back button must close the menu or dialog and return the user to the screen where the context menu or dialog box was opened.

Image For games, when the Back button is pressed during gameplay, the game can choose to present a pause context menu or dialog or navigate the user to the prior menu screen. Pressing the Back button again while in a paused context menu or dialog closes the menu or dialog.

For more information see section 5.2.4 of the Technical Certification Requirements at http://bit.ly/VpVxB7.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.206.8