Control press the "Back" button and disable the application using the confirmation dialog - wp7

I need to show a simple dialog with the question: "Do you want to exit the application?" Yes or no. This dialog will be displayed when the user clicks the back button on the device.

I know how I can show this dialog, but I do not know how to disable the reverse action: close the application.

It is always closed.

+5
source share
1 answer

, , "" , , . "", , . MainPage

MainPage()
{
  BackKeyPress += OnBackKeyPressed;
}

void OnBackKeyPressed( object sender, CancelEventArgs e )
{
  var result = MessageBox.Show( "Do you want to exit?", "Attention!", 
                                MessageBoxButton.OKCancel );

  if( result == MessageBoxResult.OK ) {
    // Do not cancel navigation
    return;
  }
  e.Cancel = true;
}
+13

All Articles