I have the following class structure
class Top : NotifyPropertyChanged
{
private List<Inner> innerList;
public bool IsInnerTrue
{
get
{
foreach (Inner inner in innerList)
{
if (inner.IsTrue)
return true;
}
return false;
};
}
}
class Inner : NotifyPropetyChanged
{
private bool isTrue;
public bool IsTure
{
get
{
return isTrue;
}
set
{
isTrue = value;
NotifyPropretyChanged("IsTrue");
}
}
}
In my view I’m binding to the IsInnerTrue property of the Top class. My problem is that I can’t figure out how to fire the PropertyChanged event for IsInnerTrue when the IsTrue property of one of the Inner objects changes value.
Does anyone have a suggestion, short of setting up an event handler for each Inner object?
Here are two options. One, subscribe to the inner PropertyChanged events:
Or two, use a dependency tracking library like Update Controls. These libraries can detect that IsInnerTrue depends upon IsTrue, and will fire the top-level property changed event when the inner property changes.