The Back button is a system-provided UI hint that enables backward navigation in the back stack or user navigation history.
It is also very simple to use, just need to modify (add) the following red code in the App.xaml.cs, it can be implemented.
Sealed Partial classapp:application {/// <summary> ///Initializes a single-instance Application object. This is the first line of the authoring code that executes,///executed, logically equivalent to main () or WinMain (). /// </summary> PublicApp () { This. InitializeComponent (); This. Suspending + =onsuspending; } /// <summary> ///called when the application is started normally by the end user. ///will be used when launching the application to open a specific file, and so on. /// </summary> /// <param name= "E" >For more information about initiating requests and procedures. </param> protected Override voidOnLaunched (Launchactivatedeventargs e) {Frame rootframe= Window.Current.Content asFrame; //do not repeat application initialization when the window already contains content.//just make sure the window is active if(Rootframe = =NULL) { //Create a frame to act as the navigation context and navigate to the first pageRootframe =NewFrame (); Rootframe.navigationfailed+=onnavigationfailed; rootframe.navigated + = rootframe_navigated; if(E.previousexecutionstate = =applicationexecutionstate.terminated) {//TODO: Loading status from a previously suspended application } //Place the frame in the current windowWindow.Current.Content =Rootframe; } if(e.prelaunchactivated = =false) { if(Rootframe.content = =NULL) { //When the navigation stack has not been restored, navigate to the first page,//and configure it by passing in the required information as a navigation parameter//ParametersRootframe.navigate (typeof(MainPage), e.arguments); } //Registering Backbutton Events Systemnavigationmanager.getforcurrentview (). backrequested + = app_backrequested; //Make sure the current window is activeWindow.Current.Activate (); } } //updates the visible information for the returned key each time the navigation event occurs private void Rootframe_navigated (object sender, NavigationEventArgs e) {Systemnavigationmanager.get Forcurrentview (). Appviewbackbuttonvisibility = ((Frame) sender). CanGoBack? AppViewBackButtonVisibility.Visible:AppViewBackButtonVisibility.Collapsed; } //titlebar return Events private void App_backrequested (object sender, Backrequestedeventargs e) {Frame rootframe = Window. Current.content as Frame; if (Rootframe = = null) {return; //e.handled The value indicates whether the application performed the requested return navigation function if (rootframe.cangoback && e.handled = = False) {e.handled = true; Rootframe.goback (); } } /// <summary> ///called when navigating to a specific page failure/// </summary> ///<param name= "Sender" >Navigating the failed framework</param> ///<param name= "E" >For more information about navigation failures</param> voidOnnavigationfailed (Objectsender, Navigationfailedeventargs e) { Throw NewException ("Failed to load Page"+e.sourcepagetype.fullname); } /// <summary> ///called when the application execution will be suspended. Without knowing the application///no need to know if the application will be terminated or restored.///and keep the contents of the memory intact. /// </summary> /// <param name= "Sender" >The source of the pending request. </param> /// <param name= "E" >more information about the pending request. </param> Private voidOnsuspending (Objectsender, Suspendingeventargs e) { varDeferral =e.suspendingoperation.getdeferral (); //TODO: Save application state and stop any background activityDeferral.complete (); } }}
Link:
Msdn:https://msdn.microsoft.com/en-us/library/windows/apps/dn439322.aspx
Reference Blog: Http://devcenter.wintellect.com/jprosise/handling-the-back-button-in-windows-10-uwp-apps
Processing of the Back button (titlebar) in UWP apps