Wednesday, October 17, 2012

Custom Control ItemsSource CallBack Not Hitting

Custom Control ItemsSource CallBack Not Hitting

Hi,

  I have developed a custom control which has an ItemsSource property of type IEnumerable. In View-Model I am binding it with a ObservableCollection. Initially it works fine i.e., during intial binding. But when the ObservableCollection is changed by adding/modifying an item, CallBack method in control is not called.

Any idea on how to resolve this issue?

 

Regards,

Raaj

 

Answers & Comments...

Answer: 1

Note that INotifyPropertyChanged and INotifyCollectionChanged are two separate interfaces implemented by ObservableCollections. If you are changing the entire collection object, PropertyChanged Callback will fire. However, when an item/ items inside the collection is/are changed, ONLY the CollectionChanged Callback will fire (and not the PropertyChanged callback). Generally when you bind a Combo/List to an ObservableCollection, both CollectionChanged and ProperyChanged are taken care of by the control...



Answer: 2

Well thanks for the information. As you mentioned, I have added a listener for CollectionChanged event and inside the listener I wrote the app logic.

Once again thanks for the suggesstion.

Regards,

Raaj





No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog