I got a scenario like this
Class Parent
{
Property A;
}
Class A
{
Property X
}
How can I get a PropertyChangedNotification
on Property A when X changes? I don’t want to refer ‘Parent’ in class A or any kind of event which spoils my decoupling. What I basically want is to make the Parent.IsDirty==true
. This is a very simplified version of my story, I got tens of classes like Parent, so I am looking for some generic way to handle this.
Please note that this is not the actual code. I got all INotifyPropertyChanged
implementation. I am just wondering any easy mechanism like RaisePropertyChanged("A.X")
You can try to register the propertychanged event in the parent class. In the constructor you can subribe to the event:
public Parent()
{
A.OnPropertyChanged += OnAPropertyChanged;
}
void OnAPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "X")
if(PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("A"))
}
hope this helps...
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