例如有一个Modelpublic class Person
{
public string Name{get;set;}
public int Age{get;set;}
}
然后让这个Person继承一个类,自动实现Name/Age变化时,界面自动更新的效果,而不用强迫Person去实现IProperychanged接口
{
public string Name{get;set;}
public int Age{get;set;}
}
然后让这个Person继承一个类,自动实现Name/Age变化时,界面自动更新的效果,而不用强迫Person去实现IProperychanged接口
依赖属性也是本身实现了INotifyPropertyChanged接口的
依赖属性也是本身实现了INotifyPropertyChanged接口的
是的,但是楼主的意思是不”强迫“
我想实现一个更简单的,就比如让Person去继承一个类,这个类里做什么我不管,我只在Person类里写两个属性,能达到我更改Person类的属性的时候触发事件或者引发OnPropertyChanged事件,再者,请看ReactiveUI里的写法,就是达到不用每次去写属性的字符串,越简单越好的目的:public class Person:ReactiveObject
{
private string _name;
private int _age;
public string Name
{
get => _name;
set => this.RaiseAndSetIfChanged(ref _name, value);
} public int Age
{
get => _age;
set => this.RaiseAndSetIfChanged(ref _age, value);
}
}