O'Reilly logo

Windows Presentation Foundation 4.5 Cookbook by Pavel Yosifovich

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

Binding hierarchical data to a TreeView

A TreeView is a common control for viewing hierarchical data. It derives from ItemsControl, but it's a bit more complex than standard controls derived from, ItemsControl, such as ListBox, because of its hierarchical nature, although it's possible to use a TreeView without data binding. Binding provides an elegant way to fill the tree with data. Let's examine this in more detail.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

We'll create an application that shows a tree view with processes as the top level objects. For each process, child tree view items will show the modules loaded into that process.

  1. Create a new WPF Application named CH06.TreeViewBinding.
  2. Open MainWindow.xaml.cs

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