O'Reilly logo

Pro Silverlight 5 in VB by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required