Search code examples
c#windows-10windows-10-mobile

How to control windows phone 10 hardware back button


I am developing WP10 application and I am navigating through pages in my app. However, the default back button is not working as it is working with windows phone 8 and windows phone 8.1

When I click the default back button the application is closed. What I want is that it should navigate to page where navigation occurred.

I used below, it works in windows 10 but it doesn't work in mobile version.

SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
SystemNavigationManager.GetForCurrentView().BackRequested += Settings_BackRequested;

private void Settings_BackRequested(object sender, BackRequestedEventArgs e)
{
    if (Frame.CanGoBack)
       Frame.GoBack();
}

How I can handle the hardware back button in windows phone 10? Thanks!


Solution

  • Solved it with Handling Back button in Windows 10 UWP