Skip to content

Instantly share code, notes, and snippets.

@HamGuy
Created July 30, 2013 03:05
Show Gist options
  • Save HamGuy/6109873 to your computer and use it in GitHub Desktop.
Save HamGuy/6109873 to your computer and use it in GitHub Desktop.
Confirm while exit
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
if (MessageBox.Show("Are you sure?", "Exit?", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
while (NavigationService.BackStack != null & NavigationService.BackStack.Count() > 0)
NavigationService.RemoveBackEntry();
}
else
e.Cancel = true;
base.OnBackKeyPress(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment