C# ReactiveUI-this.RaiseAndSetIfChanged

C# ReactiveUI-this.RaiseAndSetIfChanged,c#,wpf,.net-4.5,reactiveui,C#,Wpf,.net 4.5,Reactiveui,我通过nuget将最新的ReactiveUI(5.0.2)下载到基于.NET4.5的项目中 我创建了具有一个属性的简单视图模型类: using System; using System.Threading; using System.Windows; using ReactiveUI.Xaml; namespace ReactiveUI.Study.ViewModels { public class ShellViewModel : ReactiveObject

我通过nuget将最新的ReactiveUI(5.0.2)下载到基于.NET4.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
我刚开始学习,我不确定这个问题的根源在哪里,因为我使用的是来自

所有项目都基于.NET4.0,并且也使用旧版本的ReactiveUI

谢谢你的改变

this.RaiseAndSetIfChanged(x => x.Login, value);

现在,这是根据发行说明声明属性的唯一方法:


您是否尝试过
此.RaiseAndSetIfChanged(参考登录名,值)?@PoweredByOrange:谢谢you@PoweredByOrange这就是答案-从5开始,这个构造是唯一的版本-发布它,这样你就可以得到你应得的upvote@Murph是的,我的一位同事不久前在重构一些代码时遇到了这个问题。我只是觉得它看起来很眼熟。
this.RaiseAndSetIfChanged(ref _login, value);