Using a ViewModel to harness the power of the WPF TreeView

Microsoft's WPF TreeView control can be very difficult to work with, if you try to use it the same way that you program against a Windows Forms TreeView.  WPF's TreeView is much more feature-rich and powerful, such as having support for data binding and full visual customizations.  Those powers make the control more complicated than the WinForms equivalent.  It can be difficult to use, but it does not have to be!

The key to using the WPF TreeView control properly is to provide it with a ViewModel, essentially an abstraction of the tree's state.  The TreeView binds to its ViewModel, allowing your code to ignore the TreeView altogether.  Once you start programming against your ViewModel abstraction, it is very easy to leverage the power of the TreeView.  I published an article about this topic on CodeProject.  If you are interested in learning more about it, here's the link: http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx