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