Reputation: 1546
I have a template selector for a telerik control RadTileView. There are no errors, and everything works "fine", but the template selector SelectTemplate() never gets called, and so the program doesn't choose between my 2 data templates. Any ideas? I don't know how to debug this at all. Thank you.
My data template definition and template selector xaml code:
<DataTemplate x:Key="IncidentContentTemplate">code...</DataTemplate>
<templateselectors:TCardTileViewTemplateSelector x:Key="TCardTemplateSelector" DefaultTCardViewModelTemplate="{StaticResource contentTemplate}" IncidentTCardViewModelTemplate="{StaticResource IncidentContentTemplate}" />
</UserControl.Resources>
My Template selector:
public class TCardTileViewTemplateSelector : DataTemplateSelector
{
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (item is IncidentTCard)
{
return this.IncidentTCardViewModelTemplate;
}
else
{
return this.DefaultTCardViewModelTemplate;
}
}
public DataTemplate IncidentTCardViewModelTemplate
{
get;
set;
}
public DataTemplate DefaultTCardViewModelTemplate
{
get;
set;
}
}
My RadTileView:
<telerik:RadTileView Name="MainRadTileView"
ContentTemplate="{StaticResource contentTemplate}"
IsItemDraggingEnabled="{Binding ElementName=IsItemDraggingEnabledOption,Path=IsChecked}"
ItemsSource="{Binding Items}"
ItemTemplate="{StaticResource headerTemplate}"
ItemTemplateSelector="{StaticResource TCardTemplateSelector}"
MaximizeMode="{Binding ElementName=MaximizeModeOption,Path=SelectedItem}"
PreservePositionWhenMaximized="{Binding ElementName=PreservePositionWhenMaximizedOption,Path=IsChecked}"
TileStateChanged="tileView1_TileStateChanged"
TileStateChangeTrigger="{Binding ElementName=StateChangeOption, Path=SelectedItem}"/>
Upvotes: 0
Views: 1301
Reputation: 128061
From the Remarks section in ItemTemplateSelector:
Note that this property is ignored if ItemTemplate is set.
Simple solution: do not set the ItemTemplate
property.
Upvotes: 2