troubleshooting Question

WPF where are key bindings stored?

Avatar of deleyd
deleydFlag for United States of America asked on
* WPF.NET ProgrammingC#
1 Comment1 Solution292 ViewsLast Modified:
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"
, 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
deleyd
Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros