I have a hierarchy of observable collections, a bit like this:
interface IItem
{
ObservableCollection<IItem> Children { get; }
}
Given an IItem
(or an ObservableCollection<IItem>
) I want to construct an other observable collection that recusively contains all child IItem
items. This collection will then be used as the data source for a WPF list view (for example).
Modifying any of these items to have additional children should update the resulting observable collection. Note that there are no circular references.
I'm aware of the CompositeCollection Class and I'm sure that this should help me (I think that all I need is a composite collection recursively containining a composite collection for each child in Children
), but I can't see a neat way to do this as this class doesn't have the ability to "template" children into the required composite collection.