Browsing articles from "April, 2009"
Apr
28
2009

An Introduction to ObservableCollection in WPF

This post discusses ObservableCollection, used in WPF data binding. It describes its basic uses, along with some sample code to help you better understand how it all works.

Apr
13
2009

Creating a Custom Observable Collection in WPF

One of the biggest advantadges WPF has is its Data Binding features. Data Binding can be done in several ways, but the most common is using the INotifyPropertyChanged and INotifyCollectionChanged interfaces. For simple objects, all you need to do is implement the INotifyPropertyChanged, and raise the PropertyChanged event when your properties change. When you want to bind to a collection, you will want to use ObservableCollection<T>. This collection implements both interfaces, therefore notifying you when the items in the collection change and when the items’ properties change. This works great if you’re using standard collections. The problem arises when you want to use a custom collection. For databinding to work with custom collections, you will have to create a new “Observable” wrapper around it.