Trying to use ListView and this error always happens
ItemTemplate count has exceeded the limit of 23. Please make sure to reuse DataTemplate objects
Runtime:
Mono 5.10.57
Xamarin.Mac 4.4.1.178
Xamarin.Android 8.3.3.2
SDK Tools Version: 26.1.1
SDK Platform Tools: 27.0.1
SDK Build Tools: 27.0.3
Platform Target Frameworks: use target framework version
Nuget Packages:
Xamarin Forms 3.0.0.482510
Affected Devices:
Samsung SM-J500M (API 23)
Hi @leobragatti! Android has a limitation of the number of cell types it can use in a single ListView. If you're not reusing your DataTemplates (i.e., you return a new DataTemplate for every list item), you'll run into this limitation quickly. Please make sure you're following the instructions in https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/templates/data-templates/. If you are still unable to proceed, please attach a small project that demonstrates the issue you're having. Thanks!
Please re-open if you are still having issues after following Sams advice.
Thanks for the help @samhouts . I checked my code and I was using the TemplateSelector in a wrong way.
Most helpful comment
Hi @leobragatti! Android has a limitation of the number of cell types it can use in a single ListView. If you're not reusing your DataTemplates (i.e., you return a new DataTemplate for every list item), you'll run into this limitation quickly. Please make sure you're following the instructions in https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/templates/data-templates/. If you are still unable to proceed, please attach a small project that demonstrates the issue you're having. Thanks!