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.
- Create a new WPF Application named
CH06.TreeViewBinding
. - Open
MainWindow.xaml.cs
Get Windows Presentation Foundation 4.5 Cookbook 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.