I’ve generated an XDocument at code behind as below:
<Root>
<Pubs>
<Book id='A123'>
<Author state='AS'>Moreno</Author>
</Book>
<Book id='B456'>
<Author state='BS'>Gazit</Author>
</Book>
</Pubs>
</Root>
and want to bind this to a Treeview control in WPF application to have something like this:
+ Pubs //Pubs Element Name
+ A123 //Book Element Attribute Value
+ Moreno //Author Element Inner text
+ B456
+ Gazit
so, what is the best solution?
This Is the Answer:
For each Level of TreeView we must define a specific
HierarchicalDataTemplateinTreeView.Resourceswith:DataType= element nameItemsSource= binding child namefor example as below:
and everything is ok!