【发布时间】:2010-10-23 13:55:47
【问题描述】:
当我执行路由命令时,假设:
ApplicationCommands.Undo.Execute(null, this);
WPF 做了一些魔法来找到正确的CommandBinding,在它上面执行ExecutedRoutedEventHandler。
有没有办法获得对将被执行的CommandBinding(或至少是处理程序)的引用?
有时候调试知道谁在处理命令会很好。
【问题讨论】:
-
是的,我同意。我尝试进入 ApplicationCommands.Undo.Execute(null, this); 的 .NET 框架源代码。但我只得到“没有可用的来源”。将尝试清除我的本地符号缓存并重试。在调用堆栈中,我对 PresentationCore.dll!System.Windows.Input.CommandManager.FindCommandBinding(object sender = ... :-) 特别感兴趣
标签: c# wpf routed-commands