I have several Read-Only Properties in my View Model that are referenced by the View and some of them are dependent on one/more other Read-Only Properties (in the same View Model) which are ultimately dependent on one/more Read/Write Properties (in the same View Model). I've only seen the following pattern in samples to make sure PropertyChanged
Event is Raised for all potentially affected Properties, but I don't like duplicating all those RaisePropertyChanged Calls.
I suspect I should instead be adding a Handler to the PropertyChanged
Event of my View Model and in that Handler, for each Property which has dependent Properties, call RaisePropertyChanged on only the Properties that directly (vs. also the ones that indirectly) depend on that Property. How can I avoid duplicating all those RaisePropertyChanged Calls?
public bool MyReadOnlyPropertyAA1
{
get
{
return MyReadOnlyPropertyA1 [&& MyReadOnlyPropertyB1 ...]
}
}
public bool MyReadOnlyPropertyA1
{
get
{
return (MyPropertyA == (Some Value)) [&& MyPropertyB == (Some Other Value)) ... ]
}
}
public MyPropertyAType MyPropertyA
{
get
{
return myPropertyA
}
set
{
myPropertyA = value;
RaisePropertyChanged(nameof(MyPropertyA));
RaisePropertyChanged(nameof(MyReadOnlyPropertyA));
RaisePropertyChanged(nameof(MyReadOnlyPropertyA1));
RaisePropertyChanged(nameof(MyReadOnlyPropertyAA1));
...
RaisePropertyChanged(nameof(MyReadOnlyPropertyAA...1));
}
}
public MyPropertyBType MyPropertyB
{
get
{
return myPropertyB
}
set
{
myPropertyB = value;
RaisePropertyChanged(nameof(MyPropertyB));
RaisePropertyChanged(nameof(MyReadOnlyPropertyA));
RaisePropertyChanged(nameof(MyReadOnlyPropertyA1));
RaisePropertyChanged(nameof(MyReadOnlyPropertyAA1));
...
RaisePropertyChanged(nameof(MyReadOnlyPropertyAA...1));
}
}