15

I have asked this question on MSDN forums as well ... http://social.msdn.microsoft.com/Forums/en/wpf/thread/4493988a-9bd8-48fe-aff0-348502136a80

I need to know that why Microsoft suggests that BindingList is not properly supported in WPF...

What is it that doesnt work with BindingList in WPF? I find it pretty useful as it is. So far I personally have not found BindingList any slower or a having more load on memory.

Plus WPF ItemsControls, ItemsTemplates, Styles, Hierarchies work great with BindingLists too. They are equally observable.

Being a hardcore WPF developer myself and an ObservableCollection fan, my faith is getting shaken by a been-there-done-that BindingList....

Why should I use ObservableCollection over BindingList? (keeping aside INotifyPropertyChanged which both have to implement for item property changes)

WPF-it
  • 19,625
  • 8
  • 55
  • 71
  • Possible duplicate of http://stackoverflow.com/questions/4284663/difference-between-observablecollection-and-bindinglist – Leom Burke Mar 02 '12 at 11:41
  • 3
    @Leom, that thread also doesnt answer the question as in what is wrong with `BindingList`? – WPF-it Mar 02 '12 at 11:46
  • 2
    ObservableCollection already notifies when an item is added or removed. You don't have to implement INotifyPropertyChanged. – dcarneiro Mar 02 '12 at 11:51
  • "I need to know that it is claimed by Microsoft itself". Then I think you need to ask Microsoft and not Stackoverflow. – Martin Liversage Mar 02 '12 at 11:53
  • @Martin, its because MSDN forums have failed to address this query, I have raised it here. I know stackoverflow experts will have some insights on this. – WPF-it Mar 02 '12 at 11:56
  • 3
    @Daniel you got it wrong. He was referring to each item needing to implement INotifyPropertyChanged in order to observe changes on the item itself. – Kugel Mar 02 '12 at 12:52

1 Answers1

18

This may be of interest:

http://www.themissingdocs.net/wordpress/?p=465

most important paragraphs:

But the implementation does not scale, it is slow, it performs terribly with larger lists. If your element type supports INotifyPropertyChanged, every time one of those elements raises the property changed event the entire list is walked to work out the index in the list of the item which raised the event! I was in shock when I first realised this. You see BindingList is truly just a rather thin wrapper over Collection, so there is no metadata associated with each entry, all of the binding of the element PropertyChanged event is directed to a single handler, and all it gets given is the source and the name of the changed property, so there is no way to include the NewIndex parameter in ListChangedEventArgs without doing a search. (By default this search even uses the default object comparator, so if you happen to have two different but sometimes equal objects in your list, enjoy the results…)

Another side note – AddNew, the other feature which BindingList has which Collection does not – also does not scale. It has to use IndexOf to find out where in the list the newly added item ended up in case it needs to cancel the add, because it supports auto sorting in derived types. (BindingList does not support auto sorting itself…)

Community
  • 1
  • 1
Stephen Holt
  • 2,360
  • 4
  • 26
  • 34
  • Awesome! Thx a tonn! This is what I wanted to know... the cascade item change notifications! My faith is regained. :-) – WPF-it Mar 02 '12 at 13:44
  • 17
    The title for the linked entry is "BindingList Does Not Scale". Interesting, but read it carefully - only in the comments sections do you discover that the author's application is unusual in that he wants to show a very large number of updates in real time on his UI. Unlikely to be an issue in a more common UI scenario. – Tom Bushell Jul 02 '13 at 19:00
  • 2
    So its safe to say Binding List works fine in 99% of the wpf applications – Manvinder May 03 '15 at 06:27