Bug 60744 - [Android] Can't return different data templates using RecycleElementAndDataTemplate
Summary: [Android] Can't return different data templates using RecycleElementAndDataTe...
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.5.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-11-18 02:39 UTC by adrianknight89
Modified: 2017-11-19 05:02 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

repro (1.15 MB, application/x-zip-compressed)
2017-11-18 02:39 UTC, adrianknight89

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description adrianknight89 2017-11-18 02:39:41 UTC
Created attachment 25750 [details]

I wanted to use the new caching strategy, but I can't seem to get it working. When RecycleElementAndDataTemplate is used, OnSelectTemplate is getting hit once, hence, returning the same data template for every model instance.

If you run the repro on Android (haven't tested other platforms), all cells are either red or aqua depending on model property. In reality, this should be a mix. Change the strategy in CListView's constructor to RecycleElement instead and observe that templates are assigned correctly.
Comment 1 adrianknight89 2017-11-18 02:43:23 UTC
I forgot to add HasUnevenRows = true; to the listview, so please add that while running the project. Also, I'd like to see an automated UI test if possible.
Comment 2 adrianknight89 2017-11-19 05:02:29 UTC
Closing this after reading PR #1085 as it was clear that OnSelectTemplate is triggered once per item type.