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

Use the Same Template for Parent and Children

2 Answers 50 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
WILLIAM
Top achievements
Rank 1
WILLIAM asked on 06 Aug 2012, 03:05 PM
I'm having this issue as well.  The ItemSource for the treeview is an Office with a list of Children offices so I want to use the same template.

In that article is suggested not setting ItemTemplate property.  However, that's the only way I can get it to display the parent correctly.  Also, the children are not displaying at all.  Below is my template and treeview settings.  Am I missing a binding somewhere or do I have some property not set/not set correctly?  It's probably something simple.

Thanks for your help!!

<DataTemplate x:Key="OrgUnitsItemTemplate">
    <StackPanel Orientation="Horizontal">
        <telerik:Label Content="{Binding ParentOrgUnit.Description}" />
    </StackPanel>
</DataTemplate>
 
<telerik:RadTreeView Name="uxOrgUnits"
    SelectionMode="Extended" IsLineEnabled="True" ItemsOptionListType="CheckList"
    IsOptionElementsEnabled="True" IsDragDropEnabled="False"
    IsRootLinesEnabled="True" IsTriStateMode="True"
    ItemTemplate="{StaticResource OrgUnitsItemTemplate}">
</telerik:RadTreeView>

2 Answers, 1 is accepted

Sort by
0
WILLIAM
Top achievements
Rank 1
answered on 08 Aug 2012, 12:59 PM
???
0
Accepted
Tina Stancheva
Telerik team
answered on 08 Aug 2012, 03:57 PM
Hello William,

In order to display hierarchical information in the RadTreeView control, you need to define its ItemTemplate as a HierarchicalDataTemplate. And in order to display a hierarchy of items, which dept is undefined, you should not set the HierarchicalDataTemplate.ItemTemplate property.

I attached a sample solution demonstrating how to implement your approach. Let me know if it helps.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeView
Asked by
WILLIAM
Top achievements
Rank 1
Answers by
WILLIAM
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or