Original address: Http://www.sharpgis.net/post/2015/05/21/Displaying-a-backbutton-in-your-app-window
Disclaimer: This post is based on Windows 10 Technology Preview 10122. This may change in the future.
In Windows 10, there are apps that have a back button in the title bar at the top of them. For example, in Settings:
We can use the Appviewbackbuttonvisibility property of Systemnavigationmanager to control whether such a button is displayed.
The method used is this:
Systemnavigationmanager.getforcurrentview (). appviewbackbuttonvisibility = appviewbackbuttonvisibility.visible;
When you let your Windows generic program run on the desktop, you can see the same button appear when you run the above code. When there is enough space in the title bar, we don't need to put it anywhere else, wasting space.
Of course, on a mobile device, this line of code is not required (although you may have called it without any changes). Just in case, it's better to call it, maybe your device supports it.
//Show or hide the back button when navigating to each pageif(Frame.cangoback) Systemnavigationmanager.getforcurrentview (). Appviewbackbuttonvisibility=appviewbackbuttonvisibility.visible;ElseSystemnavigationmanager.getforcurrentview (). Appviewbackbuttonvisibility=appviewbackbuttonvisibility.collapsed;//Registers a Back button event. Call it once, and don't hold your hands cheap. For example, you can invoke a program when it startsSystemnavigationmanager.getforcurrentview (). Backrequested + = (s, e) = ={ if(Frame.cangoback) Frame.goback ();};if(Windows.Foundation.Metadata.ApiInformation.IsTypePresent ("Windows.Phone.UI.Input.HardwareButtons")){ //If the device has a back button, then the same is handled. Windows.Phone.UI.Input.HardwareButtons.BackPressed + = (s, e) = = { if(frame.cangoback) {e.handled=true; Frame.goback (); } };}
Now you can get a back button on both the desktop and the mobile platform!
Unfortunately, the arguments for the backrequested event and the backpressed event are not the same, so you cannot use the same event handler for both. This is very regrettable, I (the original author) hope that Microsoft can be resolved as soon as possible.
Translator (h82258652) Note: Because the original text literal translation comes, the feeling is too blunt, therefore some take the free translation, as far as possible with the original author's idea consistent. If you have any questions, please refer to the original text. Thank you!
"Go" "Translate" "Win10" show Back button in your program title bar