tags:

views:

70

answers:

1

I have a UI with a search text box and a button that that should be clicked when the user want to preform the search. (like a search engine UI)
I want that the same event handler will be called when the user hit the search button and when the user hit enter in the text box.

I can easily hack it but my guess is that WPF has it's own 'right' way of doing it.
So what is the WPF way of doing it right?

Thanks.

+3  A: 

There are different delegates for click and keypressed events. So extract your code in method named like 'DoSearch', then connect different (mb anonymous) handlers to events and call DoSearch inside handlers

Trickster
Thanks, that's what originally I had in mind. I failed to see that the delegates have different signatures.
Ohad Horesh