Wednesday, April 9, 2008

Collection Binding

Say you want to bind 5 data items (maybe like rows in a DataView or items in a list) to a control. Only WPF Elements that are derived from ItemsControl can show the entire list of these items.

Take a look at all the WPF elements that inherit the ItemsControl (Derived Types folder).

So what kinds of data can be bound to these controls? Anything that supports the IEnumerable interface. This would be like arrays, lists, collections. You cannot bind a DataTable (does not implement IEnumerable) to these controls but you could bind a DataView (implements IEnumerable).