How to build the Tree View from the GraphSource

2 posts, 0 answers
  1. John Tobin
    John Tobin avatar
    17 posts
    Member since:
    Mar 2008

    Posted 12 Oct 2016 Link to this post

    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}"




  2. Martin Ivanov
    Martin Ivanov avatar
    1452 posts

    Posted 13 Oct 2016 Link to this post

    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.
Back to Top