如何使发送者成为 WPF CommandBinding 中的按钮而不是主窗口?

发布于 2024-09-17 05:10:00 字数 142 浏览 1 评论 0原文

WPF MainWindow 中的 Button 具有普通的命令属性。单击时,处理程序方法接收发送者。但发送者始终是MainWidow。如何让发送者成为 Button ?我需要它成为一个特定的按钮,因为我将此命令设置为多个按钮,并且希望对多个发送者使用单个处理程序。谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寻梦旅人 2024-09-24 05:10:00

检查事件参数上的 OriginalSource,它应该包含调用该命令的发送者!

希望这有帮助!

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

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文