This question is locked. New answers and comments are not allowed.
Hello,
I have a problem in my treeview with the recursion in HierarchicalDataTemplates.
First of all, what I'm trying to achieve is a tree like this;
Type-A1
Header1
Type-B1
Type-B2
Header2
Type-A2
Header1
Type-B3
Type-B4
Header2
Type-A4
Type-A3
Type-A5
Header1
Type-B5
Header2
Type-A6
Type-A7
and my Type-A object has a Type-A list and a Type-B list. But in order to use it with a HierarchicalDataTemplate i'm combining these two lists in a single list of two lists like this;
And I'm differentiating the lists by their type in a DataTemplateSelector.
For this, I tried using the following;
But it didn't work, because TemplateA uses ABSelector, ABSelector uses HeaderTemplateA and HeaderTemplateA uses TemplateA. I'm stuck in this circular dependency among these resources. And, I couldn't figure out another way.
Am I missing some point, or is there any other way to handle this problem.
Thank you,
Nurullah
I have a problem in my treeview with the recursion in HierarchicalDataTemplates.
First of all, what I'm trying to achieve is a tree like this;
Type-A1
Header1
Type-B1
Type-B2
Header2
Type-A2
Header1
Type-B3
Type-B4
Header2
Type-A4
Type-A3
Type-A5
Header1
Type-B5
Header2
Type-A6
Type-A7
and my Type-A object has a Type-A list and a Type-B list. But in order to use it with a HierarchicalDataTemplate i'm combining these two lists in a single list of two lists like this;
List<object> CombinedList = new List<object>(){TypeAList, TypeBList};And I'm differentiating the lists by their type in a DataTemplateSelector.
For this, I tried using the following;
<UserControl.Resources> <telerik:HierarchicalDataTemplate x:Key="TemplateB"> <TextBlock Text="{Binding something}"/> </telerik:HierarchicalDataTemplate> <telerik:HierarchicalDataTemplate x:Key="HeaderTemplateB" ItemsSource="{Binding}" ItemTemplate="{StaticResource TemplateB}"> <TextBlock Text="Header1" HorizontalAlignment="Left" /> </telerik:HierarchicalDataTemplate> <telerik:HierarchicalDataTemplate x:Key="HeaderTemplateA" ItemsSource="{Binding}" ItemTemplate="{StaticResource TemplateA}"> <TextBlock Text="Header2" HorizontalAlignment="Left" /> </telerik:HierarchicalDataTemplate> <selectors:ABSelector x:Key="ABSelector" BTemplate="{StaticResource HeaderTemplateB}" ATemplate="{StaticResource HeaderTemplateA}" /> <telerik:HierarchicalDataTemplate x:Key="TemplateA" ItemsSource="{Binding CombinedList}" ItemTemplateSelector="{StaticResource ABSelector}"> <TextBlock Text="{Binding something}" /> </telerik:HierarchicalDataTemplate></UserControl.Resources><Grid> <telerik:RadTreeView ItemsSource="{Binding TypeAList}" ItemTemplate="{StaticResource TemplateA}" /></Grid>But it didn't work, because TemplateA uses ABSelector, ABSelector uses HeaderTemplateA and HeaderTemplateA uses TemplateA. I'm stuck in this circular dependency among these resources. And, I couldn't figure out another way.
Am I missing some point, or is there any other way to handle this problem.
Thank you,
Nurullah
