This is a migrated thread and some comments may be shown as answers.

How to build the Tree View from the GraphSource

1 Answer 129 Views
This is a migrated thread and some comments may be shown as answers.
John Tobin
Top achievements
Rank 1
John Tobin asked on 12 Oct 2016, 02:26 PM

Once I build a RadDiagram I have basically one List of Items and one List of Links.

Now, would it be possible to Bind a TreeView with these two objects only?


See the screenshot attached for example. The Diagram consists of four objects linked together. 

Now, Is it possible to have a TreeView representation  of the Diagram like in the screenshot attached?



From the documentation seems to be that this cannot be done, unless I create dynamically a brand new List (i.e. TreeSource) for the tree from the Items and Links objects.

Where TreeSource would basically be a:

public ObservableCollection<TreeViewNode> TreeSource;


       public class TreeViewNode {
              public string DisplayName { get; set; }
              public ObservableCollection<TreeViewNode> Nodes { get; set; } 


And the XAML

 <HierarchicalDataTemplate x:Key="TreeViewTemplate" ItemsSource="{Binding Nodes}"    >
                <TextBlock Text="{Binding DisplayName}"/>
 <telerik:RadTreeView x:Name="tree"  ItemsSource="{Binding TreeSource}"> ItemTemplate="{StaticResource TreeViewTemplate}"




1 Answer, 1 is accepted

Sort by
Martin Ivanov
Telerik team
answered on 13 Oct 2016, 10:19 AM
Hi John,

RadTreeView works only with hierarchical data, so in order to display the items from the GraphSource of the diagram you will need to convert them to a hierarchy of some kind. On way to do this is to wrap the models from the GraphSource into a hierarchical collection and pass it to the RadTreeView control. 

Another approach is to bind the GraphSource directly to the treeview using an IValueConverter and filter the data so that each RadTreeViewItem gets the corresponding data item. Such implementation is demonstrated in the Self-Referencing Data help article.

Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Asked by
John Tobin
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question