在 WPF/Prism 中,当 DelegateCommand.RaiseCanExecuteChanged 被触发时,CompositeCommand 会发生什么情况?

发布于 2024-10-04 05:55:45 字数 211 浏览 0 评论 0原文

假设我有一个 CompositeCommand,其中注册了很多 DelegateCommand。

如果子 DelegateCommands 之一触发 RaiseCanExecuteChanged,这将导致触发事件 CompositeCommand.CanExecuteChanged,在其他子级中引发相同的事件,或者它只会影响活动的 DelegateCommand?

Say that I have a CompositeCommand with a lot of DelegateCommands registered.

If one of the child DelegateCommands fires up RaiseCanExecuteChanged, this will result in firing the event CompositeCommand.CanExecuteChanged, raising this same event in the other children, or it will only affect the active DelegateCommand?

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

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

发布评论

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

评论(1

度的依靠╰つ 2024-10-11 05:55:45

刚刚想通了这一点。通过分析 Prism 的内部结构,我注意到 CompositeCommand 在其子级的 CanExecuteChanged 事件中注册自身。因此,每次注册命令引发 CanExecuteChanged 处理程序时,复合命令都会在其自身及其所有子命令中执行相同的操作。

Just figured this out. By analyzing the internals of Prism, I noticed that the CompositeCommand registers itself in its children's CanExecuteChanged event. Thus, everytime a registered command raises the CanExecuteChanged handler, the composite command does the same in itself and in all of its children.

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