Is binding of ItemsControl to ObservableCollection <T> more efficient than List <T>?
I have a render item template in ItemsControland you want to minimize the recreation of child templates when it ItemsSourcesignals a change. I am wondering if it ObservableCollectioncan pinpoint WPF exactly what has changed (as opposed to the whole list), if it is more efficient at rendering changes to the collection, or if WPF is smart enough to reuse previous representations of elements if it detects that the same element still in change list.
Your suspicion is true. WPF will not reuse previous views. If you replace the ItemSource of the ItemsControl with a new List, it will create completely new views for each item in the list, even if the same items were in the old list.
You can test this yourself by putting a user control in an ItemTemplate and adding a break or debug point to its constructor. If you replace the ItemSource with an identical list, you will see that your control is configured once for each item in the list. On the other hand, when an element is added to the ObservableCollection, you will see it only once.
, ItemsControl (, ListBoxItem), . . http://blogs.msdn.com/b/vinsibal/archive/2008/05/14/recycling-that-item-container.aspx. .