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

LoadTemplate should not be null

2 Answers 261 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Louis asked on 08 Jul 2020, 04:10 PM


I've only just begun evaluating Telerik for Xamarin Forms over Syncfusion and I've immediately ran into an issue with the ListView. I'm using a DataTemplateSelector for the item template of the list and it's throwing an exception:

System.InvalidOperationException: LoadTemplate should not be null
   at Xamarin.Forms.ElementTemplate.CreateContent()
   at Telerik.XamarinForms.DataControlsRenderer.UWP.ExtendedListViewItem.UpdateTemplate(RadListView listView, Object dataItem)
   at Telerik.XamarinForms.DataControlsRenderer.UWP.UWPListView.PrepareContainerForItem(RadListViewItem item, Object context)
   at Telerik.UI.Xaml.Controls.Data.ListView.View.Controls.ListViewItemUIContainerGenerator.PrepareContainerForItem(GeneratedItemModel el

This is the list view in xaml:

<telerikDataControls:RadListView ItemsSource="{Binding Mappings.Items}"
                                     ItemTemplate="{StaticResource CaseTemplateSelector}"
                                     BackgroundColor="{x:Static resources:Colours.PageBackground}"

The template selector is added to static resources via the application resources container in App.xaml along with the DataTemplates that are returned from the OnSelectTemplate method. The OnSelectTemplate method always returns a value, or it throws an exception, a breakpoint on this method does not get hit before the exception fires.

Are there any special measures required for RadListView to use DataTemplateSelector? Switching back to the Xamarin Forms ListView works fine on all platforms (once I remove the Reorder properties in the xaml) and I haven't found anything in the documentation for this being a known issue. Is there something I'm missing or is this just not possible with RadListView?


2 Answers, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 08 Jul 2020, 04:54 PM

Looks like I made a mistake with the template property, I was setting the template selector to "ItemTemplate" as you would with the standard Xamarin Forms ListView. I've changed that to ItemTemplateSelector and the exception no longer fires, however the cells weren't rendering. Some more checking of the documentation and I've now got my Grid layout of the cells embedded in a ListViewTemplateCell.View which is embedded in a ListViewTemplateCell embedded within the DataTemplate. Now I'm finding that the tapped event is not firing, removing SelectionMode="None" has not fixed it either.

Seems like there are a lot of hoops to jump through when using Telerik as opposed to Syncfusion which was much easier to pick up and start using.

Lance | Manager Technical Support
Telerik team
answered on 08 Jul 2020, 05:05 PM

Hello Louis,

The first issue I see is that you would not typically use a TemplateSelector instance for the ItemTemplate property (is this how Syncfusion does it?). The ItemTemplate property should point to a resource of type DataTemplate, not an instance of an extended DataTemplateSelector.

To use a template selector class, it would be set on the RadListView's ItemTemplateSelector property. For example:

         ItemsSource="{Binding Mappings.Items}"
         ItemTemplateSelector="{StaticResource CaseTemplateSelector}" 
         ... />

You can find a full tutorial in the RadListView's ItemTemplateSelector documentation article.

Possible 2nd Problem

Since you did not share the relevant code, I'll need to make a guess on this one. Please double check that DataTemplate is not still using a ViewCell, it should be a ListViewTemplateCell.

Please review the RadListView documentation's Cell Types article which shows a full example using ListViewTemplateCell. For your convenience, here's the relevant code:

<DataTemplate x:Key="MyItemTemplate">
            <!-- Your ItemTemplate content -->

Note: The 'tlv' XML namespace is:



Further Assistance

If you have any further trouble, please open a Support Ticket here so that you can directly interact with the Xamarin support and development team quickly (you have unlimited technical support during your trial period).

An added bonus to Support Ticket is that it is confidential conversation that you can attach ZIP files to. Attaching the relevant code allows us to quickly see all the relevant parts and provide an answer much sooner (instead of wasting time going back and forth asking for missing code).

Thank you for reaching out and for trying UI for Xamarin!

Lance | Manager - Technical Support
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question