In the development of the Windows Phone 7 program, there is no way to exit the program. You can only use the back button on the mobile Phone.
If you want to click the back button on the page to exit, a dialog box will pop up to confirm with the user, which can be implemented as follows:
1 public MainPage ()
3 InitializeComponent ();
5 this. BackKeyPress + = new EventHandler <System. ComponentModel. CancelEventArgs> (MainPage_BackKeyPress );
Define the exit button handler:
1 void MainPage_BackKeyPress (object sender, System. ComponentModel. CancelEventArgs e)
3 if (MessageBox. Show ("are you sure you want to exit this program? "," Reminder ", MessageBoxButton. OKCancel) = MessageBoxResult. Cancel)
5 e. Cancel = true; // operation canceled
In this way, the confirmation dialog box is displayed when you click the back button on the MainPage.
When the input method is called, clicking the back button only hides the input method and does not trigger the BackKeyPress event on the page.