Reputation: 4390
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.
Upvotes: 0
Views: 758
Reputation: 2524
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
Upvotes: 3