Choose the Page where you want to Override “Back key ”
In .CS page declare “using System.ComponentModel;” on Top
Copy The Code Below and paste it where ever you want handle Back Key press event.
- using System.ComponentModel;
-
- protected override void OnBackKeyPress(CancelEventArgs e)
- {
- if (MessageBox.Show("Are you sure you want to exit?", "Attention !!!",
- MessageBoxButton.OKCancel) != MessageBoxResult.OK)
- {
- e.Cancel = true;
- }
- }