Previously, I had a class that wrapped an internal System.Collections.Generic.List
(where Item is a class I created). The wrapper class provided se
The system treats anything that implements IList
(or IListSource
) as a container, rather than an item. As such, you cannot bind to properties of anything that implements IList
. As such, encapsulation (i.e. what you already have) is the best approach if you want to be able to bind to properties of the container.
However, you should note that many bindings support dot-notation in the source - i.e. either binding to "Items.SomeProperty", or setting the auxiliary property (typically DataMember
) to specify sub-lists.
This allows you to have a single BindingSource
, and have different controls bound to different levels in the hierarchy - i.e. you might have a TextBox
bound to AverageValue
, and a DataGridView
(with the same DataSource
) that has DataMember="Items"
.