I want the Escape key to close the WPF window. However, if there is a control that can use this Escape key, I do not want to close the window. There are several solutions on how to close the WPF window when you press the ESC key. eg. How does the WPF Button.IsCancel property work?
However, this solution closes the window, regardless of whether there is an active control that can use the Escape key.
For example, I have a window with a DataGrid. One of the columns in the dataGrid is a combobox. If I change the ComboBox and hit Escape, then the control should exit comboBox (Normal Behavior) editing. And if I remove Escape again, the Window should close. I would like to get a general solution instead of writing a lot of custom code.
If you can provide a solution in C #, that would be great.
source
share