I have a TreeView which data source is generated in runtime through code to which I don't have access. Its hierarchical data, nodes of tree with 2, 3 or 4 depth levels. I have to make the same structured tree with RadioButtons corresponding to every object in first tree. Is there a way to iterate through every element of TreeView or another method to do my task?
Asked
Active
Viewed 49 times
1 Answers
0
In WPF, we use DataTemplate
s, or in your case HierarchicalDataTemplate
s to define how our data should be presented. You already have the data in the first TreeView
and that should be accessible from its ItemsSource
or Items
properties. Therefore, all you need to do is to define another HierarchicalDataTemplate
to display the same data object the way that you want it. There is no need to manually iterate through all of the nodes from the original TreeView
.

Sheridan
- 68,826
- 24
- 143
- 183