I am developing a WPF application, which has many windows in it. As usual, main window allows to open other windows. I want to create application-level hotkeys (shortcuts), which would open the particular window, and would work in every window of my application.
I have tried using CommandBinding in my MainWindow class, see the example below, but it works if the main window has focus only (as it actually should). I have also tried the second way from this question Application Level shortcut keys in WPF, and created binding to a key "P", but whenever I press P, even if it is a TextBox input text or something like that, the window is opened.
I expect the hotkeys work in every window of my application, but not if it is a text input or something else. I might be wrong using the solution, for which I have provided a link, if so, I would be very grateful to someone who explains me how to use it properly.