We have a collection of items we bind to a treeview control.
Is it possible to bind hierarchical collections? That is, an item in the collection might itself be a collection. The members of the collection would be displayed in the treeview as children of the collection object.
Or will we have to construct the tree programatically?
Thanks for any insights…
(And another thing… Is it possible to filter the items that are displayed (something like what a converter does for an individual value)? Or should we filter the raw collection into a collection to be bound and displayed by the treeview?)
Yes, you can use the
TreeViewcontrol in conjunction withHierarchicalDataTemplateobjects to bind to a hierarchical data structure. MSDN has a “how-to” article available here.As far as the “filtering” part of your question goes, you could do it either way (using a converter, or filtering programmatically). Without knowing more of the details of your implementation I’m hesitant to make a recommendation.