作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我通过 nuget 下载最新的 ReactiveUI (5.0.2) 到我基于 .NET 4.5 的项目。
我创建了具有一个属性的简单 View 模型类:
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。
谢谢
最佳答案
改变
this.RaiseAndSetIfChanged(x => x.Login, value);
到
this.RaiseAndSetIfChanged(ref _login, value);
这是现在根据发行说明声明属性的唯一方法:
https://github.com/reactiveui/ReactiveUI/blob/master/docs/migrating-from-rxui4.md
关于c# - ReactiveUI - this.RaiseAndSetIfChanged,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17791969/
我通过 nuget 下载最新的 ReactiveUI (5.0.2) 到我基于 .NET 4.5 的项目。 我创建了具有一个属性的简单 View 模型类: using System; using Sy
我正在使用 ReactiveCommand: LoginCommand = new ReactiveCommand(this.WhenAny(x => x.UserName, x => x.Passw
我是一名优秀的程序员,十分优秀!