Saturday, December 26, 2015

How to Enable Back Button In Windows 10 UWP

Enable back button in the app title bar Windows 10 UWP

In Windows 10 UWP the back button is disabled by default. If you need back button in the application title bar you need to enable it. I will show how to enable this button.

 Write the following code to enable the back button.

 protected override void OnNavigatedTo(NavigationEventArgs e)
  {

            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame.CanGoBack)
            {
                // If we have pages in our in-app backstack and have opted in to showing back, do so
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            }
            else
            {
                // Remove the UI from the title bar if there are no pages in our in-app back stack
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
            }
        }

No comments:

Post a Comment

Useful xamarin link

Xamarin blog https://blog.xamarin.com/ Xamarin show at channel 9 https://channel9.msdn.com/Shows/XamarinShow?page=2 Xamarin videos a...