Hello, I have problems trying to apply different templates to my RadListView on Xamarin Forms.
If I declare my templates as resources on my xaml, i.e.:
<ResourceDictionary>
<DataTemplate x:Key="templatePortrait" x:Name="templatePortrait">
<telerikListView:ListViewTemplateCell>
<telerikListView:ListViewTemplateCell.View>
<Grid VerticalOptions="FillAndExpand" BackgroundColor="{StaticResource LightGrayBackgroundColor}">
<Grid.RowDefinitions>
<RowDefinition Height="50*" />
<RowDefinition Height="30*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60*"/>
<ColumnDefinition Width="40*"/>
</Grid.ColumnDefinitions>
</Grid>
</telerikListView:ListViewTemplateCell.View>
</telerikListView:ListViewTemplateCell>
</DataTemplate>
<DataTemplate x:Key="templateLandscape" x:Name="templatePortrait">
<telerikListView:ListViewTemplateCell>
<telerikListView:ListViewTemplateCell.View>
<Grid VerticalOptions="FillAndExpand" BackgroundColor="{StaticResource LightGrayBackgroundColor}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*"/>
<ColumnDefinition Width="50*"/>
</Grid.ColumnDefinitions>
</Grid>
</telerikListView:ListViewTemplateCell.View>
</telerikListView:ListViewTemplateCell>
</DataTemplate>
</ResourceDictionary>
and then I change the item template of my listview when I rotate the device, simply in this way:
listView.ItemTemplate = templateLandscape;
or
listView.ItemTemplate = templatePortrait;
it doesn't work, seems that the new template is not applied.
Instead if I assign the itemtemplate in this way:
listView.ItemTemplate = new DataTemplate(typeof(Templates.TelerikLandscape));
all works as expected. Why?
Where is my mistake?
Thank you