TreeView

The TreeView is another important control, and WPF provides its own implementation that exposes a TreeView.Items collection where you nest nodes. Each node is represented by a TreeViewItem object. You can build complex items as in the following example:

image

The text in the node is specified with the Header property while additional information can be assigned with the Tag property. Assigning the Name property is also useful because you can interact with nodes in managed code. To add nodes at runtime you simply create an instance of the TreeViewItem class and then add it to the specified node as demonstrated here:

Figure 32.23 shows the result ...

Get Visual Basic® 2010 Unleashed 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.