参考问题:(是否有使用 Reactive UI 订阅分层属性更改的模式?)
我目前在我的父反应对象中有一个子反应对象。
public class Child : ReactiveObject
{
private string propertyX
public string PropertyX
{
get { return this.propertyX; }
set { this.RaiseAndSetIfChanged(x => x.PropertyX, ref this.propertyX, value); }
}
private string propertyY
public string PropertyY
{
get { return this.propertyY; }
set { this.RaiseAndSetIfChanged(x => x.PropertyY, ref this.propertyY, value); }
}
}
public class Parent: ReactiveObject
{
public Parent(Child child)
{
Child = child;
this.WhenAny(x => x.Child.PropertyX, x => x.Value).Subscribe(x => raisePropertyChanged("Child"));
}
private Child child
public Child Child
{
get { return this.child; }
set { this.RaiseAndSetIfChanged(x => x.Child, ref this.child, value); }
}
}
我的问题是我必须写:
this.WhenAny(x => x.Child.PropertyX, x => x.Value).Subscribe(x => raisePropertyChanged("Child"));
每个子属性?
我需要这样做的原因是因为嵌套的属性绑定,我的 DevExpress 网格不会更新。
<dxg:GridColumn x:Key="PropertyX" Header="PropertyX" FieldName="Child.PropertyX" />