Hi when I do in one of my user controls in a WPF application,
this.KeyUp += new KeyEventHandler(ControlViewer_KeyUp);
or
this.KeyDown += new KeyEventHandler(ControlViewer_KeyUp);
or
this.AddHandler(Window.KeyDownEvent, new KeyEventHandler(ControlViewer_KeyUp), true);
I can never get the key events to fire when pusing a key on the keyboard.
Would anyone know why?
the event is probably being handled before you can get to it, if any handlers mark the KeyEventArgs e.Handled = true;
you wont get the notification, try using the PreviewKeyDown
or PreviewKeyUp
events and see if you have more luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With