"Go" "Translate" "Win10" show Back button in your program title bar

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.