加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 将Mvvm Light更新为版本5后,我需要做哪些更改才能使RelayC

发布时间:2020-12-15 04:10:39 所属栏目:百科 来源:网络整理
导读:我将Mvvm Light更新为版本5并注意到RelayCommand停止工作. 问题似乎是没有调用CanExecute()进行验证.它只验证一次,就像加载窗口时一样. 这可能是最近更新中的错误还是我需要在XAML中更改某些内容? 在更新之前一切正常.我正在使用WPF. 解决方法 见 MVVM Ligh
我将Mvvm Light更新为版本5并注意到RelayCommand停止工作.

问题似乎是没有调用CanExecute()进行验证.它只验证一次,就像加载窗口时一样.

这可能是最近更新中的错误还是我需要在XAML中更改某些内容?

在更新之前一切正常.我正在使用WPF.

解决方法

见 MVVM Light 5 issue:

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.

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.

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.

Definitely not looking for excuses

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读