WP8.1 Double-click the two-time return key to exit the program

Source: Internet
Author: User

To implement a two-click Return key to exit the program on a Windows Phone implementation, one method is to use the toastprompt provided by Coding4Fun, using the following method:

1. Install the reference and open the package Manager Console.

Enter the following command to install Coding4Fun.Toolkit.Controls

Install-package Coding4Fun.Toolkit.Controls

Enter the following command to install GalaSoft.MvvmLight.Messaging

Install-package Mvvmlight

2. In the code, add the following reference

using Coding4Fun.Toolkit.Controls; using GalaSoft.MvvmLight.Messaging;


3. In the MainPage () constructor, register the agent function of Messenger and implement the function

Public MainPage () {Messeger.Default.Register<bool> (this, (l) = =  Changeexitstate (L));} BOOL false ; Private void Changeexitstate (bool= value;}

4. In the Backkey_pressed event, implement tap two to exit

Private voidMainpage_backpressed (Objectsender, Backpressedeventargs e) {if(!isexit) {Isexit=true;varToast =Newtoastprompt {Message ="Press once again to exit the program"};toast.completed+ = (o, ex) = {messenger.default.send<BOOL> (false); };toast. Show (); e.handled=true;}Else{e.handled=true; Application.Current.Exit ();}}

WP8.1 Double-click the two-time return key to exit the program

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.