WPF - Handling a RoutedEvent in the parent for a specfic control instance
- by empo
In my user control I have several textboxes e.g. Textbox1, Textbox2.
In the parent I only want to handle KeyDown events raised from Textbox1, not all Textbox
I have added a handler in the parent
this.AddHandler(TextBox.KeyDownEvent, new RoutedEventHandler(OnTextboxGoToPageKeyDown));
but of course this will handle all KeyDown events which I don't want.
Do I have to add some conditional logic in the RoutedEventHandler to check where the event was raised from?
or is there a better way?
What's the best way to do this?
Thanks.