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

HierarchicalDataTemplate

1 Answer 121 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Ali Rafiee
Top achievements
Rank 1
Ali Rafiee asked on 07 Feb 2012, 10:15 PM

I'm trying to display a list of items and their children in a TreeListView.

The children are not the same type as parent items, so I looked into useing a HierarchicalDataTemplate, but I can't get it to work.

I did a little digging and saw some posts that said TreeListView does not support parent child relationships of different types, but then saw another post where someone had defined one, but I can't get it to work. (http://www.telerik.com/community/forums/silverlight/treelist/silverlight-3-radtreelistview-hierarchicaldatatemplate-question.aspx)

Does it or doesn't support HierarchicalDataTemplate?

What I have is this:

public class Parent
{
   public string Name {get; set;}
   public List<Child> Items { get; set; }
}
 
public class Child
{
   public string ItemRTF { get; set; }
}

<UserControl.Resources>
     <telerik:HierarchicalDataTemplate x:Key="ChildTemplate">
         <telerik:RadRichTextBox Background="Yellow" IsReadOnly="true" />
     </telerik:HierarchicalDataTemplate>
     <telerik:HierarchicalDataTemplate x:Key="ParentTemplate" ItemTemplate="{StaticResource ChildTemplate}" ItemsSource="{Binding Items}">
         <sdk:Label Background="Green"  Content="{Binding Name}"/>
     </telerik:HierarchicalDataTemplate>
 </UserControl.Resources>
 
 <Grid x:Name="LayoutRoot" Background="White">
     <telerik:RadTreeListView Margin="12,12,12,37" Name="myTreeListView" ItemTemplate="{StaticResource ParentTemplate}" AutoGenerateColumns="False">
         <telerik:RadTreeListView.Columns>
             <telerik:GridViewColumn Width="*"/>
         </telerik:RadTreeListView.Columns>
     </telerik:RadTreeListView>
</Grid>


1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 08 Feb 2012, 10:16 AM
Hi,

 The RadTreeListView displays the data in a tree view manner in one and the same table.
It could be used for displaying of homogeneous data or data that has the same properties. If the data is heterogamous, the the TreeListView will display only the properties with the same name. In order to display the hierarchy data, you should use the ChildTableDefinitions property. This property should have the same name at each level of the hierarchy. As the hierarchical data in the TreeListView is displayed in one and the same table, each level of the hierarchy will share one and the same set of columns. This means that your data should provide the needed members at each level of the hierarchy.

Kind regards,
Didie
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
TreeListView
Asked by
Ali Rafiee
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or