开发者

How to make sender to be a Button and not the MainWindow in WPF CommandBinding?

开发者 https://www.devze.com 2023-01-14 04:52 出处:网络
The Button in WPF MainWindow has normal command attribute. When clicked the handler method receives sender. But the sender is always MainWidow. How to get sender to be a Button ? I need it to be a par

The Button in WPF MainWindow has normal command attribute. When clicked the handler method receives sender. But the sender is always MainWidow. How to get sender to be a Button ? I need it to be a particular button, because I set this command to several buttons and want to use single handler for many开发者_运维百科 senders. Thank you


Check the OriginalSource on the event arguments, it should hold the sender who invoked the command!

Hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消