查找 RoutedEvent 的目的地

发布于 2024-09-28 21:22:35 字数 251 浏览 1 评论 0原文

当我执行路由命令时,假设:

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 技术交流群。

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

发布评论

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

评论(1

骷髅 2024-10-05 21:22:35

您可以尝试检查 CommandBinding 列表:

       UIElement
       ContentElement 
       UIElement3D

ApplicationCommands 正在内部检查发送者是否在 CommandBinding 中具有特定命令。此外,如果 sender 为 null,则将 Keyboard.FocusedElement 指定为发送者。

You can try to check the CommandBinding lists in:

       UIElement
       ContentElement 
       UIElement3D

ApplicationCommands are checking internally if sender has particular command in CommandBinding. In addition if sender is null then Keyboard.FocusedElement is assigned as sender.

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