When and where to use NotifyPropertyChanged

137 views Asked by At

Could someone explain the use of notify property changed and in which cases should I be using it?

For example: I have in my silverlight application the domain data source which loads data and the event LoadedData where I set to some lists (List) the content of the entities from the domain context and bind the lists to the girds.

Do I need to use NotyfiPropertyChanged on the Lists?

Thanks,

1

There are 1 answers

0
toadflakz On BEST ANSWER

I think you are getting the concepts slightly confused here...

There are two relevant notification interfaces for use with XAML Binding technologies.

INotifyCollectionChanged - notifies listeners when the collection of items changes (as in add/remove/replace/reorder actions).

INotifyPropertyChanged - notifies listeners that the content of an object has changed (as in values have been set and itself and other properties have changed).

In your case, if you want to notify that the contents of the List have changed, you need to use an INotifyCollectionChanged enabled collection to do that (i.e. not List - typically ObservableCollection).

If you wanted to notify that an item within the List has changed then the object type contained in the List should implement INotifyPropertyChanged.