Bug 60382 - CachingStrategy=RecycleElement displays out of order items again in 2.4.x (iOS and Android)
Summary: CachingStrategy=RecycleElement displays out of order items again in 2.4.x (iO...
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.5.0
Hardware: Other Other
: Normal blocker
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-10-25 23:16 UTC by Cliff Cawley
Modified: 2017-10-28 02:46 UTC (History)
3 users (show)

Tags: listview, cachingstrategy, recycleelement, ac
Is this bug a regression?: Yes
Last known good build:

Sample to reproduce bug (56.79 KB, application/zip)
2017-10-25 23:16 UTC, Cliff Cawley

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 Cliff Cawley 2017-10-25 23:16:56 UTC
Created attachment 25461 [details]
Sample to reproduce bug

Looks like this old bug has appeared again.  (iOS and Android)

1) Open the attached sample
2) Run the app
3) Scroll up and down and notice that the items while they started in order, get out of order as items are recycled
4) Set the CachingStrategy to RetainElement and run again and notice the items are ordered correctly

Sample is attached.
Comment 1 Chris King 2017-10-27 21:58:25 UTC
Cliff, on what version of XF did this work?
Comment 2 Cliff Cawley 2017-10-27 23:14:44 UTC
Hmm I was sure it was working in but looks like it's not working correctly there either.

I went back as far as and it seems to not be working there either.

I normally use templates and sometimes a selector for my lists but this is using one of the default templates.

Perhaps it works fine with custom templates, just not the default templates, and never has?
Comment 3 Cliff Cawley 2017-10-27 23:21:11 UTC

So I can confirm it must be the default TextCell!

If I create my own class with a Title property and use that instead of the strings in the list, and then do:

                        <Label Text="{Binding Title}" />

Then the items are all correctly ordered.

So custom DataTemplate items are working just fine, it's just if you use the default ItemTemplate that's set by the ListView that it's broken.

Probably not nearly as high priority as I thought because in all but the simplest of cases you're going to want to customize the list items anyway.
Comment 4 Chris King 2017-10-28 00:16:11 UTC
Yeah, that's what I found. Most real apps provide a template. 

Actually, what you observed originally is expected behavior: Essentially, by not providing a template the app is seeing uninitialized cells; without a template XF populates cells with label ToString values of the ItemsSource. If the cells are recycled and the app forgos updating the context by not supplying a TemplateSelector, then the cell retains the content that was previously there. As iOS randomly recycles cells, the cells appear to be "out-of-order".

Ideally, the default renderer would actually be a default _template_ but because ListView is already so complicated and because folks usually supply a template, then (unless there is objection), we're gonna close this out.
Comment 5 Cliff Cawley 2017-10-28 02:46:24 UTC
No worries :)