Link to home
Start Free TrialLog in
Avatar of deleyd
deleydFlag for United States of America

asked on

WPF where are key bindings stored?

In a WPF application, say I have a window, and I set up a key binding to run a command if I press a certain key on the keyboard.

Somewhere in my Window object I expect my key binding is stored. I expect when a key is pressed on the keyboard, that generates a "key was pressed" event, and the operating system determines which window has focus, (and perhaps what control on the window has focus,) and sends the "key was pressed" event to to window, and the window has a list of events it handles, and if there's a match then it calls the corresponding event handler.

But I can't find that list.

Maybe it doesn't work that way. Maybe the window registers the events it's interested in with some higher power, and that higher power keeps the list of events the window handles.

Either way, my problem is I press the key, and... nothing happens.

So I'm trying to trace what happens to this key event, because it's not resulting in my command being called.

Also, is there a list of keyboard key names that can be used in WPF XAML files? I've seen the list of Key Enumerations at https://msdn.microsoft.com/en-us/library/system.windows.input.key(v=vs.110).aspx. It lists "OemPlus" for the keyboard "+" key; however, I've seen XAML code that uses
key="Plus"

Open in new window

, which seems to work, but I don't see that documented anywhere.

So my questions are:

1. Is there documentation for what key names can be used in a WPF XAML file for the "Key="<string>"

2. Is there a way to trace what happens to a keyboard key pressed event when what I'm expecting to happen doesn't happen?
ASKER CERTIFIED SOLUTION
Avatar of deleyd
deleyd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial