Use the Same Template for Parent and Children

3 posts, 1 answers
  1. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 06 Aug 2012 Link to this post

    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. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 08 Aug 2012 Link to this post

    ???
  3. DevCraft banner
  4. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 08 Aug 2012 Link to this post

    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.

Back to Top