WPF - Canvas does not respond to key press anymore
I have an application where I can click on a canvas and when I hit the Enter key, a polygon is drawn with my clicked locations as corners. I do work with MVVM, so everything is using
{Binding ...}
. I catch both the mouse click and the key press via Interaction.Triggers
. Now, next to my canvas are a few buttons. They do not have any functionality yet, there is no command binding so far on those buttons. Now everything works fine, until I click one of those buttons. Let's say I draw a few polygons on my canvas, then I start drawing a new one (by clicking on the canvas). When I now click on one of those yet-functionless buttons and then want to hit enter to draw the polygon on the canvas, the key pressed is no longer recognized.
I can keep clicking on the canvas and it does recognize the mouse clicks, but the enter key just won't work anymore. It doesn't call the command that was bound to the key press.
Why is that and how do I solve that? I'm losing my mind.2 Replies