WPF – Bind XDocument to TreeView with Checkboxes?

Up vote 0 down vote favorite share g+ share fb share tw.

I would like to bind an XDocument to a TreeView, which has a checkbox on each item, and when you check items, it cascades to its parent and children (using indeterminate state when some children are checked and others are not). I have been able to create a simple binding of an XmlDocument in xaml using HierarchicalDataTemplates. One of the problems is that I would prefer to work with an XDocument instead of XmlDocument.

Also I can create the Checkboxes and so forth inside the HierarchicalDataTemplate, but I can’t get it to link to the items very well. I know how to inplement the checkboxes with a wrapper class where I recursively visit the parents and children, but whenever I traverse the TreeViewItem, its TreeViewItem. Items property is filled with XmlElements instead of TreeViewItems like it should.

Is there a way I can create a wrapper class and have it bind to that without having to manually load the xml document into the tree (which became very slow when I tried to do this, as it is a large xml document). By the way, I also intend to add more custom stuff to each treeview item like a second set of checkboxes, etc., so it seems like finding a way to get the binding to be wrapped in a class for each treeview item might be the way to go. ` More Info: I think part of the problem I am having is that in all the exapmles I find with ViewModel's attached, they do something like this in the HierarchicalDataTemplate: DataType="{x:Type local:CheckableItem}", whereas in mine I have to use DataType="Dataset" in order to let the binding know that it is the nodes that this template applies to.

I do not know how to combine these 2. Wpf xaml binding treeview xdocument link|improve this question edited Jun 6 '11 at 19:29 asked Jun 6 '11 at 18:54user38052714711 92% accept rate.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions