查找 RoutedEvent 的目的地
当我执行路由命令时,假设:
ApplicationCommands.Undo.Execute(null, this);
WPF 使用一些魔法来找到正确的 CommandBinding,并在其上执行 ExecutedRoulatedEventHandler。
有没有办法获取对要执行的 CommandBinding(或至少是处理程序)的引用?
有时,了解谁在处理命令对于调试来说是很好的。
When I execute a routed command, let's say:
ApplicationCommands.Undo.Execute(null, this);
WPF does some magic to find the proper CommandBinding
on which it executes the ExecutedRoutedEventHandler
.
Is there a way to get a reference to the CommandBinding
(or at least to the handler) that would be executed?
It would sometimes be nice for debugging to know who is handling a command.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试检查 CommandBinding 列表:
ApplicationCommands 正在内部检查发送者是否在 CommandBinding 中具有特定命令。此外,如果 sender 为 null,则将 Keyboard.FocusedElement 指定为发送者。
You can try to check the CommandBinding lists in:
ApplicationCommands are checking internally if sender has particular command in CommandBinding. In addition if sender is null then Keyboard.FocusedElement is assigned as sender.