How can I assign the 'Close on Escape-key press' behavior to all WPF windows within a project?
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 bother to manually setup the command- and input bindings but I wonder if repeating this XAML in all windows is the most elegant approach? <Window.CommandBindings> <CommandBinding Command="Close" Executed="CommandBinding_Executed" /> </Window.CommandBindings> <Window.InputBindings> <KeyBinding Key="Escape" Command="Close" /> </Window.InputBindings> Any constructive suggestions welcome! All I can suggest to improve on that is