The TreeView

The TreeView control allows you to display items in a collapsible, hierarchical tree, just like the kind that are a staple of the Windows world, appearing in everything from the Windows Explorer file browser to the .NET help library.

At its heart, the TreeView is a specialized ItemsControl that hosts TreeViewItem objects. The trick is that each TreeViewItem is its own distinct ItemsControl, with the ability to hold more TreeViewItem objects. This flexibility allows you to create a deeply layered data display.

Filling a TreeView

Here's the skeleton of a very basic TreeView, which is declared entirely in markup:

<controls:TreeView>   <controls:TreeViewItem Header="Fruit">     <controls:TreeViewItem Header="Orange"/>     <controls ...

Get Pro Silverlight 5 in VB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.