Xamarin.forms: [Android] ItemTemplate count has exceeded the limit of 23. Please make sure to reuse DataTemplate objects

Created on 4 Jun 2018  ·  3Comments  ·  Source: xamarin/Xamarin.Forms

Description

Trying to use ListView and this error always happens
ItemTemplate count has exceeded the limit of 23. Please make sure to reuse DataTemplate objects

Steps to Reproduce

  1. Just trying to use a ListView

Basic Information

  • IDE: VisualStudio Community Mac 7.5.2 (build 40)
  • 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

    • Android: API Level 15
  • Nuget Packages:
    Xamarin Forms 3.0.0.482510

  • Affected Devices:
    Samsung SM-J500M (API 23)

needs-info ❓ needs-repro ❔

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!

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings