Referring to question: (Is there a pattern for subscribing to hierarchical property changes with Reactive UI?)
I currently have a child reactiveobject in my parent reactiveobject.
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); }
}
}
My question is that do I have to write:
this.WhenAny(x => x.Child.PropertyX, x => x.Value).Subscribe(x => raisePropertyChanged("Child"));
for each child property?
The reason I need to do this is because my DevExpress grid will not update because of the nested property binding.
<dxg:GridColumn x:Key="PropertyX" Header="PropertyX" FieldName="Child.PropertyX" />
So, it's a bit of a hack, but you can always "forward" a property:
this.WhenAny(x => x.Child.PropertyX, x => x.Value).ToProperty(this, x => x.PropertyXFromChild, out propertyXFromChild);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With