Hi, this question is going to show my lack of understanding of the expected behavior when implementing/using INotifyPropertyChanged:
The question is - for binding to work as expected, when you have a class which itself implements INotifyPropertyChanged, that has nested properties of type INotifyPropertyChanged are you expected to internally subscribe to change notification for these properties and then propogate the notifications? Or is the binding infrastructure expected to have the smarts to make this unnecessary?
For example (note this code is not complete - just meant to illustrate the question):
public class Address : INotifyPropertyChanged
{
string m_street
string m_city;
public string Street
{
get { return m_street; }
set
{
m_street = value;
NotifyPropertyChanged(new PropertyChangedEventArgs("Street"));
}
}
public string City
{
get { return m_city; }
set
{
m_city = value;
NotifyPropertyChanged(new PropertyChangedEventArgs("City"));
}
}
public class Person : INotifyPropertyChanged
{
Address m_address;
public Address
{
get { return m_address = value; }
set
{
m_address = value;
NotifyPropertyChanged(new PropertyChangedEventArgs("Address"));
}
}
}
So, in this example we've got a nested Address object in a Person object. Both of which implement INotifyPropertyChanged so that alteration of their properties will result in transmission of property change notifications to subscribers.
But let's say using binding someone is subscribing to change notification on a Person object, and is 'listening' for changes to the Address property. They will receive notifications if the Address property itself changes (a different Address object is assigned) but WILL NOT receive notifications if the data contained by the nested address object (the city, or street) are changed.
This leads to the question - is the binding infrastructure expected to handle this, or should I within my implementation of Person be subscribing to change notifications on the address object and then propagating them as changes to "Address"?
If you get to this point, thanks for just taking the time in reading this long winded question?
Comment much appreciated!
Phil