I’m sure there is a simple answer to this but I can’t seem to find it. Most examples for binding TreeView nodes are about using a ListView to show the node’s details. In the scenario I am working on I’ve got a TreeView data bound to an Xml document using a simple MVVM pattern. As each node is selected in the TreeView I want to show a different UserControl for the type of XmlNode being represented.
- What is the best control for hosting the different View’s? (ViewBox, Panel?)
- What’s the best way to bind the view to the Selection in the treeview?
Thanks
In an application I’m working on I have a similar scenario. You should use UserControl to host your views.
In the TreeView each item controls its own IsSelected state. Have you tried binding to the TreeView’s SelectedItem property? What I actually did was create an attached property for the mouse double click, and bound it to a Command. I defined this binding in my HierarchicalDataTemplate.