我通过nuget将最新的ReactiveUI (5.0.2)下载到基于.NET 4.5的项目中。
我用一个属性创建了简单的视图模型类:
using System;
using System.Threading;
using System.Windows;
using ReactiveUI.Xaml;
namespace ReactiveUI.Study.ViewModels
{
public class ShellViewModel : ReactiveObject
{
#region Properties
private string _login;
public string Login
{
get
{
return _login;
}
set
{
this.RaiseAndSetIfChanged(x => x.Login, value);
}
}
}
}当我尝试编译我的项目时,我得到异常
Cannot convert lambda expression to type 'ref string' because it is not a delegate type我刚开始学习,我不确定这个问题的根源在哪里,因为我使用的是来自https://github.com/reactiveui/ReactiveUI.Samples/blob/master/ReactiveUI_4Only.Samples.sln的示例
而且所有的项目都是基于.NET 4.0的,并且也使用旧版本的ReactiveUI。
谢谢
发布于 2013-07-23 03:11:43
变化
this.RaiseAndSetIfChanged(x => x.Login, value);至
this.RaiseAndSetIfChanged(ref _login, value);现在,这是根据发行说明声明属性的唯一方法:
https://github.com/reactiveui/ReactiveUI/blob/master/docs/migrating-from-rxui4.md
https://stackoverflow.com/questions/17791969
复制相似问题