Today, I finally resolved an issue that I thought was related to WPF’s focus implementation. For some reason, I couldn’t get certain elements to get focus when I clicked on them. This was messing up a number of other things, including keyboard interactions and routed commands. I thought that I had some strange scenario that was preventing focus from going to my canvas. Maybe some issue with FocusScopes? Maybe the control wasn’t Focusable?

It turns out that I had a number of event handlers set up for clicking, dragging, etc. In these, I was setting e.handled = true. Not good!

There are cases where you’ll want to set e.handled to true, but be careful. In my case, this prevented a mouse click from moving focus to the control.

Cheers!