I have a custom WPF control that wants to handle both key down and up events as well as text input. For instance, if the user hits Home on the keyboard, I want to handle that in my custom control and prevent it from bubbling up to other controls.
Now, I can achieve this by handling the key down and up events in my custom control and settingKeyEventArgs.Handled
to true
. However, this has the unfortunate side effect that text input events then aren't getting generated.
How do I handle both key down and key up events as well as text input without letting the events propagate to parent controls. I want to work pretty much like the TextBox control, which can handle both Home and End without letting the events propagate, while also handling actual text input.