daniel-luberda / DLToolkit.Forms.Controls

Xamarin.Forms Custom Controls
Apache License 2.0
393 stars 182 forks source link

Recycling opacity #253

Closed marekbuban closed 5 years ago

marekbuban commented 5 years ago

Hello,

I have a FlowListView with 4 columns and CachedImage in each column. By default image has opacity set to 0.5, when image is tapped (selected) its opacity is set to 1. The problem is, if I select (for example) first image on first row and then just scroll down, every first image on every 6th row has also opacity set to 1, even image on this 6th row was not selected and was supposed to have default opacity (0.5). I think this has something to do with caching, but I was not able to resolve the issue. It's not a problem of CachedImage component same happens for OoB Image control. ImageSource is correctly set, no caching for this property, only for Opacity.

Any ideas? Thanks!

marekbuban commented 5 years ago

Ok, I've resolved the issue myself. The problem was of course with the caching strategy which is for FlowListView defined to RecycleElements. I didn't find out how this can be changed/defined in XAML, but I found in source code there's another constructor with CachingStrategy. So I defined it from codebehind, I've created new FlowListView instance where I defined caching strategy:

DLToolkit.Forms.Controls.FlowListView FlowListViewInstance = new DLToolkit.Forms.Controls.FlowListView(ListViewCachingStrategy.RetainElement);

I know this is not ideal for very long lists, but I hope it can handle my 200 items (50 rows) per list on many devices.