We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

TreeViewAdv: impossible to apply different template depending on element type ?

Let's take two different classes, one for parent, one for children :

public class ParentElement
 public string ParentName { get; set; }
 public IEnumerable<ChildElement> Children { get; set; }

public class ChildElement
 public string ChildName { get; set; }

And some ViewModel :

public class SomeViewModel
 public IEnumerable<ParentElement> Parents { get; set; }

I have no problem using TreeView to apply different templates for parents and children :

<sdk:TreeView x:Name="TvControl" ItemsSource="{Binding Parents}">
  <template:HierarchicalDataTemplate ItemsSource="{Binding Children}">
   <TextBlock Text="{Binding ParentName}"/>
      <TextBlock Text="{Binding ChildName}"/>

However, HierarchicalDataTemplate seems to have a completely different behavior when used by TreeViewAdv and I just couldn't find a way to apply two different templates for Parents and Children elements.

When using the code above with TreeViewAdv instead of TreeView never brings the inner template (the one with the ChildName property) to the screen.

Is there any way to do this to reproduce with TreeViewAdv the behavior I get with TreeView ?


6 Replies

KR Karthick Ravichandran Syncfusion Team June 14, 2013 11:05 AM UTC

Hi Xavier,


Thanks for using Syncfusion products.


We have created a sample based on your requirement “two different templates for parent and child elements in TreeViewAdv”. Please find the attached sample.


Please let us know if you have any queries.





XN Xavier Nesi June 18, 2013 07:16 AM UTC



Thank you for your answer. Unfortunately, I get the same behavior I had with my tests, meaning the child template is never used and the ChildName property never displayed.


I forgot to tell, maybe is it relevant, but my project is targeting Silverlight 5.

KR Karthick Ravichandran Syncfusion Team June 24, 2013 11:07 AM UTC

Hi Xavier,


Thanks for your update.


We have checked the sample with Silverlight 5 and we are unable to reproduce the problem. We have attached a sample in which we tried in Silverlight 5. Could you please modify the sample to reproduce the problem and provide the information like currently which syncfusion version you are using. This would be help for us to analyze the problem.


Please let us know if you have any other queries.





XN Xavier Nesi June 24, 2013 12:45 PM UTC


the problem is there when I execute your code as-is. I don't have to modify anything. I just open your solution, compile and execute it, and the ChildName property is never displayed.


The Essential Studio release is The Syncfusion..Tools.Silverlight dll is






KR Karthick Ravichandran Syncfusion Team July 2, 2013 10:46 AM UTC

Hi Xavier,
Sorry for the inconvenience caused.
We are able to reproduce the issue “while using HierarchicalDataTemplate children element never displayed” in version and we have created an incident #110228 for your query. Please follow up on the incident for further updates.
Please let us know if you have any queries.

XN Xavier Nesi July 5, 2013 08:48 AM UTC

It's working. Awesome job, thanks !

Live Chat Icon For mobile
Up arrow icon