mvvm light MIX10 演示 RelayCommand 问题

发布于 2024-09-29 23:19:56 字数 361 浏览 0 评论 0原文

有人看过 Laurent Bugnion 在 MIX10 上的精彩演示吗?如果您喜欢 MVVM-light,我认为它是必看的,我确实有一个无法解决的问题...在使用 RelayCommand 的演示中,他做了两个示例 - 一个是我们实现 Icommand 本身一种是使用 MVVM Light 中的 RelayCommand。在第二个示例中,他特别指出,当 Counter 属性更改时,您需要在 SayHello 命令中调用 RaiseCanExecuteChanged。但我评论了这一点并且它有效...

抱歉 - 你必须熟悉演示才能得到这个问题,但我希望有人可能...我也希望有人可以解决这个问题 - 我似乎不知道为什么我们需要做他所说的事情,因为否则效果很好。

谢谢!!!

Has anyone seen Laurent Bugnion's great demo at MIX10? If you are into MVVM-light I would call it a must see, I do have a question that I can't see to figure out... In the demo that uses RelayCommand, he does two examples - one where we implement Icommand itself and one where use RelayCommand from MVVM Light. On the second example he specifically says that you need to call RaiseCanExecuteChanged in the on the SayHello command when the Counter property changes. but I commented this out and it works...

Sorry - you have to be familiar with the demo to get this question but I hope someone might be... I also hope someone can clear this up - I don't seem to know why we need to do what he is talking about cause it works just fine otherwise.

Thanks!!!

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

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

发布评论

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

评论(1

缱倦旧时光 2024-10-06 23:19:56

我无法谈论驱动此问题的具体内部接线,因此请记住我的评论。

我相信数据绑定将定期(有时​​智能地)重新查询 ICommand 的 CanExecute 方法。调用 RaiseCanExecuteChanged 是确保按钮尽快重新查询的一种方法。

如果其他人可以解释按钮何时决定何时重新查询,我也很想知道。

I can't speak to the specific internal wiring that drives this, so take my comments with that in mind.

I believe that data binding will routinely (and sometimes intelligently) requery the CanExecute method of ICommand. Calling RaiseCanExecuteChanged is a way of ensuring that button will requery it as soon as possible.

If anyone else can explain when buttons decide when to requery, I'd love to know that too.

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