Values selected in a picker are cleared when you scroll down a collection view and then back up. I found the same issue was logged for the ListView: https://github.com/xamarin/Xamarin.Forms/issues/4250. I altered the sample from issue 4250 to use a CollectionView and I can reproduce the issue.
Steps to Reproduce
Expected Behavior
Picker values should not clear
Actual Behavior
Picker values cleared
Basic Information
Reproduction Link
Picker_CollectionView_Issue.zip
Probably related to this
https://github.com/xamarin/Xamarin.Forms/issues/9200
I'm using a bindable stacklayout to work around this issue since I don't have very many items in the list. Performance seems to be fine.
I'm using a bindable stacklayout to work around this issue since I don't have very many items in the list. Performance seems to be fine.
@jrpickett For smaller numbers of items, using a BindableLayout is an excellent choice. The BindableLayout will create instances of all your templated items, rather than using a pool of recycled items like CollectionView does. (See https://github.com/xamarin/Xamarin.Forms/issues/9200#issuecomment-643822589 for a more detailed explanation of what CollectionView is doing.)
If you find later that you need a larger number of items than BindableLayout can handle, you can add a property in your view model for the Picker's selection and bind the Picker to it.
Why is this closed? The problem is still not fixed, my picker value gets cleared aswell when scrolling up or down...
Has anyone found a workaround for this one? I just encountered it deep into a redesign and it's killing me.
Okay, the BindableLayout worked as an alternative. It's a shame that CollectionView has errors on all the platforms, I'm not sure it's usable for anything very complex at this point.
Okay, the BindableLayout worked as an alternative. It's a shame that CollectionView has errors on all the platforms, I'm not sure it's usable for anything very complex at this point.
It's true. BindableLayout works for this. Sorry that I didn't respond faster..
I don't understand why it's closed actually.
To use BindableLayout is a workaround and it doesn't work fine in all cases.
For example, there is pretty large collection of items in my app and I want tot use ColeectionView instead of BindableLayout because of virtualization and performance improvements. But I can't because of this very, very weird issue.
Any suggections?
Why is this closed? The problem is still not fixed, my picker value gets cleared aswell when scrolling up or down...
@cmpalmer66 @programmingworld1 @abondarenko
This was closed because it's not a bug. As I suggested upthread, you should take a look at the comments for issue 9200 for an explanation of why it's not a bug and how to use the CollectionView/CarouselView with data binding to achieve your goal.
I'm using binding and the thing is binded property is empty after a scrolling.
@abondarenko What does your DataTemplate and your Binding look like? Can you post your XAML/code?
Most helpful comment
Why is this closed? The problem is still not fixed, my picker value gets cleared aswell when scrolling up or down...