Reputation: 6514
I have textbox catching KeyDown events like this:
<Style TargetType="TextBox">
<EventSetter Event="KeyDown" Handler="TextBoxInput"/>
</Style>
It works for all key and key combinations except spacebar. Even space with modifiers works ok, only space alone does not come to my method.
Is there anything I can change on the textbox to fire the event also on spacebar alone?
Upvotes: 1
Views: 2516
Reputation: 67898
Use the PreviewKeyDown
event instead of KeyDown
.
<EventSetter Event="PreviewKeyDown" Handler="TextBoxInput"/>
And you can use this article as backing for that.
Upvotes: 4