WPF - Handling a RoutedEvent in the parent for a specfic control instance

Posted by empo on Stack Overflow See other posts from Stack Overflow or by empo
Published on 2010-06-10T12:40:17Z Indexed on 2010/06/10 12:42 UTC
Read the original article Hit count: 428

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about routedevents