Will anyone direct me to some simple, graphical tutorial on how to use ObservableCollection. I went through msdn but I don't seem to understand them. I can't seem to find better ones on google either. I'm looking for simple example with full explanation on all steps.
An ObservableCollection is a dynamic collection of objects of a given type. Objects can be added, removed or be updated with an automatic notification of actions. When an object is added to or removed from an observable collection, the UI is automatically updated.
The true difference is rather straightforward:ObservableCollection implements INotifyCollectionChanged which provides notification when the collection is changed (you guessed ^^) It allows the binding engine to update the UI when the ObservableCollection is updated. However, BindingList implements IBindingList.
The observable collection works just the same way. If you add or remove something to or from it: someone is notified. And when they are notified, well then they call you and you'll get a ear-full. Of course the consequences are customisable via the event handler.
I don't know of any graphical tutorial of ObservableCollection
. The ObservableCollection<T>
class is a collection type (like List<T>
) which means that it holds objects of a given type T
. What makes ObservableCollection
special is that it "tells" observers when a new object is added or when an object is removed. This is especially useful for UI's implemented using WPF, because esentially, when an object is added to or removed from an observable collection, the UI is automatically updated. This happens because, when binding to an observable collection, WPF automatically adds an event handler to the ObservableCollecion
's CollectionChanged
event.
If you know how to use a List , use a List and after that just replace the world 'List' with 'ObservableCollection'.
That's all !! isn't it simple ? :)
And now, every time the collection is changed (item been added\ removed\ replaced) Your bounded UI will be notified about it.
This is a nice introductory article: http://www.codeproject.com/KB/silverlight/SLListVsOCollections.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With