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

HierarchicalDataTemplate question

1 Answer 122 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Artem
Top achievements
Rank 1
Artem asked on 13 Feb 2012, 01:01 PM
Hi. I have class
public class Tree
{
public string Name {get;set;}
public ObservableCollection<MyClass1> Folder1{get;set;}
public ObservableCollection<MyClass2> Folder1{get;set;}
public ObservableCollection<MyClass3> Folder1{get;set;}
}
 
public class MyClass1
{
public string Name;
public ObservableCollection<MyClass4> someData
}
public class MyClass2
{
public string Name;
public ObservableCollection<MyClass5> someData
}
public class MyClass3
{
public string Name;
public ObservableCollection<MyClass6> someData
}

And I want create tree that look like

TreeName
       |
       MyClass1Element
                     |
                      MyClass4Element
       |
        MyClass2Element
                      |
                        MyClass5Element
       |
        MyClass3Element
                        |
                         MyClass6Element


Please tell me what I must do for this tree?

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 15 Feb 2012, 05:22 PM
Hi,

You could take a look at the following article as a start: http://www.telerik.com/help/silverlight/radtreeview-populating-with-data-hierarchical-data-templates.html 

You could use ItemTemplate property of the HierarchicalDataTemplate element to provide data template (or hierarchical template) for the children of the element.

<DataTemplate x:Key="ThirdLevelTemplate">
    <TextBlock Text="{Binding Name}" />
</DataTemplate>
 
<telerik:HierarchicalDataTemplate x:Key="SecondLevelTemplate"
        ItemsSource="{Binding Items}"
        ItemTemplate="{StaticResource ThirdLevelTemplate}">
    <TextBlock Text="{Binding Name}" />
</telerik:HierarchicalDataTemplate>
 
<telerik:HierarchicalDataTemplate x:Key="FirstLevelTemplate"
        ItemsSource="{Binding Items}"
        ItemTemplate="{StaticResource SecondLevelTemplate}">
    <TextBlock Text="{Binding Name}" />
</telerik:HierarchicalDataTemplate>

You could also take a look at our online demos for inside and samples: http://demos.telerik.com/silverlight/#TreeView/FirstLook.

Hope this helps, please let us know if you need further assistance.
Regards,
Hristo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
TreeView
Asked by
Artem
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or