当我执行路由命令时,假设:
ApplicationCommands.Undo.Execute(null, this);
WPF 做了一些神奇的事情来找到它在其上执行 ExecutedRoutedEventHandler
的正确的 CommandBinding
。
有没有办法获取对将要执行的 CommandBinding
(或至少是处理程序)的引用?
有时知道谁在处理命令对于调试来说会很好。
最佳答案
您可以尝试检查 CommandBinding 列表:
UIElement
ContentElement
UIElement3D
ApplicationCommands 正在内部检查发送者是否在 CommandBinding 中有特定的命令。此外,如果 sender 为 null,则 Keyboard.FocusedElement 被指定为发件人。
关于c# - 查找 RoutedEvent 的目的地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4004310/