Is there any straightforward way of telling the whole WPF application to react to Escape key presses by attempting to close the currently focused widow? It is not a great bo
None of above worked for me, except Kai's. I modified his answer: I added 'btn_close.IsCancel = true;' to constructor. SettingsWindow is my second window, and main window is (default) MainWindow.
public partial class SettingsWindow : Window {
public SettingsWindow() {
InitializeComponent();
btn_close.IsCancel = true;
}
private void btn_close_Click(object sender, RoutedEventArgs e) {
this.Close();
}
}
Hope it helps,
Simon S love nia