Win10 Desktop and Mobile Extensions API to determine if there is an entity back key API

Source: Internet
Author: User

Hi Big Ben's win10 UAP Development Preview version finally out, this update with 8.1 change is not very big, but the original win8.1 and WP8.1UAP of the sub-project form, instead of integration into a project, after a compilation packaged into a appx package, to achieve a seamless cross-platform.

Each platform-specific API becomes the extension API, the following

Below, take the WP unique fallback key for example, look at the use of different platform extension API.

If you create a new WIN10UAP project, run on WP running, you will find that back key unexpectedly he meow is backstage! This is not the job of robbing the home key!

Some of the styles of the page, unexpectedly is the upper left corner of the virtual back key, this perverse behavior of Microsoft you really enough!

Be sure to find back the function of back!!

The extension API is used:

1.ADD References

2. Select Universal App platform–extensions

3. Tick the Windows Mobile Extension SDK

4. Happy to use Windows.Phone.UI.Input.HardwareButtons.BackPressed + = hardwarebuttons_backpressed;

This code in the WIN10 desktop run is crash, because the desktop version does not have this API, so need to use

Windows.Foundation.Metadata.ApiInformation.IsTypePresent ("Windows.Phone.UI.Input.HardwareButtons")

The runtime determines whether there is support for the API.

So, the final code might be:

12345 if   ( Windows.Foundation.Metadata.ApiInformation.IsTypePresent ( " Windows.Phone.UI.Input.HardwareButtons "          {//http:// Www.liubaicai.net/archives/444              windows.phone.ui.input.hardwarebuttons.backpressed-= hardwarebuttons_backpressed;              Code class= "CSharp Plain" >windows.phone.ui.input.hardwarebuttons.backpressed + = hardwarebuttons_backpressed;         
123456789 privatevoidHardwareButtons_BackPressed(objectsender, Windows.Phone.UI.Input.BackPressedEventArgs e){http://www.liubaicai.net/archives/444    e.Handled = true;    Frame rootFrame = Window.Current.Content as Frame;    if(rootFrame.CanGoBack)        rootFrame.GoBack();    else        Application.Current.Exit();}

So happily realized the back key back function.

Win10 Desktop and Mobile Extensions API to determine if there is an entity back key API

Related Article

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.