更新MVVM轻至第5版,做什么样的变化,我需要作出RelayCommand CanExecute()之后的工作? [英] After updating Mvvm Light to Version 5, what changes do I need to make RelayCommand CanExecute() work?

查看:413
本文介绍了更新MVVM轻至第5版,做什么样的变化,我需要作出RelayCommand CanExecute()之后的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新MVVM轻至5版本,发现 RelayCommand 停止工作。

I updated Mvvm Light to version 5 and noticed that RelayCommand stopped working.

这个问题似乎是在 CanExecute()不会被调用来验证。它仅验证一次,当加载窗口等。

The problem seems to be that the CanExecute() is not being called to validate. It only validates one time, like when the window is loaded.

难道这是从最近更新的错误或者是有什么我需要在XAML改变?

Could this be a bug from the recent update or is there something I need to change in the XAML?

一切都在更新之前正常工作。我与WPF工作。

Everything was working correctly before the update. I'm working with WPF.

推荐答案

请参阅本的 MVVM光5问题

WPF是使用CommandManager可以
的唯一XAML框架自动地提高对个ICommand的CanExecuteChanged事件。我从来没有
喜欢这种做法,因为神奇的部分,但是这是WPF的
的功能,当然我要支持它。这里没有问题。

WPF is the only XAML framework that uses the CommandManager to automagically raise the CanExecuteChanged event on ICommands. I never liked that approach, because of the "magic" part, but this is a "feature" of WPF and of course I have to support it. No question here.

在V5,我搬到便携式类库的XAML框架,包括WPF4.5的所有最新版本的
。不幸的是,在没有PCL
命令管理,我必须承认,我不知道一见钟情是
。所以,当然现在的自动魔法的部分不工作
了。再次,所以我们对此深感抱歉。

In V5, I moved to portable class library for all the newest versions of the XAML frameworks, including WPF4.5. Unfortunately, there is no CommandManager in PCL, and I have to admit that I didn't realize that at first sight. So of course now the automagical part doesn't work anymore. Again, so sorry about that.

我不希望你用命令管理在后抬起CanExecuteChanged现在到处,不是
您的应用程序,这是什么
WPF团队意。所以我会尽量找到一种方法来恢复该工具包的WPF4.5版本
命令管理使用

I am not expecting you to raise CanExecuteChanged everywhere now, not after using the CommandManager in your application, which is what the WPF team intended. So I will try to find a way to restore the CommandManager usage in the WPF4.5 version of the toolkit.

绝对不找借口;),但希望解释为什么
问题的发生,有助于理解这一点。这将是我的首要任务
1号,直到我找到一种方法在PCL版本解决这个问题。在此期间,就像我前面提到的,我觉得要回
V4.4.32.7应该解决这个问题。请让我知道,如果它没有。

Definitely not looking for excuses ;) but hope that explaining why the issue arose helps to make sense of this. It's going to be my priority No. 1 until I find a way to solve this in the PCL version. In the meantime, like I mentioned before, I think that going back to V4.4.32.7 should fix that. Please let me know if it does not.

所以临时推荐的解决方案是即可恢复到以前的版本。我做到了,它的工作。

So the temporary recommended solution is to revert back to the previous version. I did it and it worked.

我同意CommandManager是做神奇。有一次,我在 CanExecute 状态的结果中和了空引用例外,我获得了无止境的错误消息的周期就像在Windows纸牌卡。如果我开始了一个新项目,我宁愿不要使用这种神奇而是改变现有的和已经部署的项目将是相当痛苦的。

I agree that the CommandManager is doing "magic". Once I had null reference exception within the CanExecute condition and as a result I have obtained neverending cycle of error messages like cards in Windows Solitaire. If I started a new project I would prefer not to use this "magic" but to change an existing and already deployed project would be quite painful.

这篇关于更新MVVM轻至第5版,做什么样的变化,我需要作出RelayCommand CanExecute()之后的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆