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

ItemTemplateSelector example needed

2 Answers 98 Views
BreadCrumb
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 11 Feb 2012, 10:58 AM
Hi telerik,

I am working on my first Breadcrumb. It binds  (on Level 1) to a flat ObservableCollection, on the following levels on a hierarchical/self-referencing entity set. I am therefore trying to use the ItemTemplateSelector property but it seems the TemplateSelector's SelectTemplate() method never gets called.

1. I got the same thing working OK with a RadTreeView.
2. If I define a HierarchicalDataTemplate within the breadcrumb directly, the binding works but only for Level 1 and 2, i.e. the self-referencing part is missing - unsurprisingly, as the template is designed for level 1/2 only.

Would you have any example how to use TemplateSelector with RadBreadCrumb? 
Your help most appreciated, thx,
bluewater

My breadcrumb:
<telerik:RadBreadcrumb Name="Breadcrumb" Grid.Column="1" Grid.Row="3" 
                       ItemsSource="{Binding Serviceclasses}"
                       ItemTemplateSelector="{StaticResource myDataTemplateSelector}"                                   
                       >

My Selector XAML:
<UserControl.Resources>
 
    <telerik:HierarchicalDataTemplate x:Key="ChildServicegroupsTemplate"
                                      ItemsSource="{Binding Path=ChildServicegroups}">
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding Sortkey}" Margin="0,0,10,0"  />
            <TextBlock Text="{Binding Code}" FontWeight="Bold" />
            <TextBlock Text="{Binding Name}" Margin="10,0,0,0" />
        </StackPanel>
    </telerik:HierarchicalDataTemplate>
 
    <telerik:HierarchicalDataTemplate x:Key="ServicegroupsTemplate"
                                      ItemsSource="{Binding Path=ChildServicegroups}"
                                      ItemTemplate="{StaticResource ChildServicegroupsTemplate}" >
 
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding Sortkey}" Margin="0,0,10,0"  />
            <TextBlock Text="{Binding Code}" FontWeight="Bold" Foreground="Blue" FontSize="12"  />
            <TextBlock Text="{Binding Name}" Margin="10,0,0,0" Foreground="Blue" FontSize="12" />
        </StackPanel>
    </telerik:HierarchicalDataTemplate>
 
    <telerik:HierarchicalDataTemplate  x:Key="ServiceclassTemplate" 
        ItemTemplate="{StaticResource ServicegroupsTemplate}" 
        ItemsSource="{Binding Servicegroups}" >
 
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding Name}" Foreground="Green" FontSize="24"  />
        </StackPanel>
    </telerik:HierarchicalDataTemplate>
     
    <itsf:ServicegroupsTemplateSelector x:Key="myDataTemplateSelector" 
        ServiceclassTemplate="{StaticResource ServiceclassTemplate}"  
        ServicegroopRootTemplate="{StaticResource ServicegroupsTemplate}"
        ServicegroupChildTemplate="{StaticResource ChildServicegroupsTemplate}"/>
 
</UserControl.Resources>

My template selector is basically right from your league/division/team example, with the required mods

2 Answers, 1 is accepted

Sort by
0
Accepted
Zarko
Telerik team
answered on 15 Feb 2012, 04:29 PM
Hi,
Thank you for the feedback. We are aware of the problem with the ItemTemplateSelector and you can track the problem on this issue here. Meanwhile, there are two possible workarounds:
- if you want to use the ItemTemplateSelector you'll have to edit the default template of the RadBreadcrumb (it's about 1000 lines of XAML)
- instead of an ItemTemplateSelector you can use a ItemContainerStyleSelector and select a style with HeaderTemplate setter for each individual item.
I've attached two project that show this workarounds so could you please examine it and if you have more questions feel free to ask. 

Regards,
Zarko
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Frank
Top achievements
Rank 1
answered on 17 Feb 2012, 08:06 AM
thank you Zarko. I appreciate your support.
Tags
BreadCrumb
Asked by
Frank
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Frank
Top achievements
Rank 1
Share this question
or