Dynamically updating treeview node wpf

Since everything is data bound, we can’t just place static tree nodes somewhere inside the tree once we committed to bindings.The solution I used here is to have helper view models; that is, have some intermediate types that provide the correct information.The process object here needs to have two child objects that somehow produce “Threads” and “Modules” and these should have child objects of themselves that are the actual threads and modules objects.The Process class doesn’t have these kinds of properties.

But we want to have two child nodes directly under a process named Threads and Modules, and each one having the relevant items, something like this: At first this may seem simple, but it’s not obvious (at least it wasn’t for me).In this post I want to share some techniques we can use to work with a Tree View while binding and using appropriate data templates.Adding items to a Tree View with no binding is fairly easy – just add Tree View Item objects and set their Header property (or set a Header to a data object and modify Header Template).One missing control from Win RT that exists in WPF is the Tree View (there is a Win RT version in the Win RT XAML Toolkit, however).The Tree View has its own unique challenges when trying to bind collections to it.

Leave a Reply