Working with the Back button (XAML) in a Windows Phone app

Source: Internet
Author: User

Unlike PCs, all Windows Phone devices have a Back button that allows users to navigate backwards between the pages of the app. If the user presses the back button again when they go to the first page of the app, the operating system suspends your app and navigates the user to the app's pre-launch experience. The experience might be another app, or it might be the start screen. This topic discusses how your app should handle backpressed events to provide a consistent user experience.

Handling backpressed Events

The most thing to know about the backpressed event that is raised when the user presses the back button is: If your app is not set by setting the backpressedeventargs.handled property to True To handle the event, the operating system suspends your app and brings the user back to the previous experience. So, in an event handler, if your app can navigate backwards, you need to do this, and then set the backpressedeventargs.handled property to true. If your app is on the first page and cannot navigate backwards, you should not handle the event, and the operating system will suspend your app. Fortunately, the logic for this situation is provided by default in the Windows Phone app's template. The following code is provided in the App.xaml.cs file.

Private void Hardwarebuttons_backpressed (object  sender, Backpressedeventargs e) {    as  Frame;     ifnull)    {        return;    }     if (frame. CanGoBack)    {        frame. GoBack ();         true ;    }}

Turn from:

Https://msdn.microsoft.com/zh-cn/library/windows/apps/xaml/dn639128.aspx

Working with the Back button (XAML) in a Windows Phone app

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.