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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

109222 Jun 4,2013 10:33 AM UTC Jul 5,2013 08:48 AM UTC Silverlight 6
loading
Tags: FAQ
Xavier Nesi
Asked On June 4, 2013 10:33 AM UTC

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}">
 <sdk:TreeView.ItemTemplate>
  <template:HierarchicalDataTemplate ItemsSource="{Binding Children}">
   <TextBlock Text="{Binding ParentName}"/>
    <template:HierarchicalDataTemplate.ItemTemplate>
     <DataTemplate>
      <TextBlock Text="{Binding ChildName}"/>
     </DataTemplate>
    </template:HierarchicalDataTemplate.ItemTemplate>
  </template:HierarchicalDataTemplate>
 </sdk:TreeView.ItemTemplate>
</sdk:TreeView>

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 ?

 


Karthick Ravichandran [Syncfusion]
Replied On 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.

 

Regards,

Karthik



TreeViewBindingDemo_b7d82f00.zip

Xavier Nesi
Replied On June 18, 2013 07:16 AM UTC

Hi,

 

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.


Karthick Ravichandran [Syncfusion]
Replied On 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.

 

Regards,

Karthik



TreeViewBindingDemo_SL5_a4d44bba.zip

Xavier Nesi
Replied On June 24, 2013 12:45 PM UTC

Hi,

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 11.1.0.21. The Syncfusion..Tools.Silverlight dll is 11.104.0.21.

 

 

 

 

 


Karthick Ravichandran [Syncfusion]
Replied On 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 11.1.0.21 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.
Regards,
Karthik

Xavier Nesi
Replied On July 5, 2013 08:48 AM UTC

It's working. Awesome job, thanks !


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;