Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Picker value cleared when scrolling a CollectionView in iOS #9659

Closed
jrpickett opened this issue Feb 21, 2020 · 16 comments
Closed

Picker value cleared when scrolling a CollectionView in iOS #9659

jrpickett opened this issue Feb 21, 2020 · 16 comments

Comments

@jrpickett
Copy link

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: #4250. I altered the sample from issue 4250 to use a CollectionView and I can reproduce the issue.

Steps to Reproduce

  1. Run the sample
  2. Scroll down CollectionView items
  3. Now scroll the up the CollectionView items and you can see that the picker values cleared.

Expected Behavior
Picker values should not clear

Actual Behavior
Picker values cleared

Basic Information

  • Version with issue: Xamarin Forms 4.4.0.991640 and 4.5.0.282-pre4
  • IDE: Visual Studio Enterprise 2019 version 16.4.2 on Windows 10
  • Platform Target Frameworks:
    • iOS: 13.2
    • Android: not tested
    • UWP: not tested
  • Affected Devices: iPad Air

Reproduction Link
Picker_CollectionView_Issue.zip

@jrpickett jrpickett added s/unverified New report that has yet to be verified t/bug 🐛 labels Feb 21, 2020
@PureWeen
Copy link
Contributor

Probably related to this
#9200

@PureWeen PureWeen added a/collectionview and removed s/unverified New report that has yet to be verified labels Feb 21, 2020
@jrpickett
Copy link
Author

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.

@hartez
Copy link
Contributor

hartez commented Jun 14, 2020

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 #9200 (comment) 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.

@hartez hartez closed this as completed Jun 14, 2020
@programmingworld1
Copy link

Why is this closed? The problem is still not fixed, my picker value gets cleared aswell when scrolling up or down...

@cmpalmer66
Copy link

cmpalmer66 commented Aug 12, 2020

Has anyone found a workaround for this one? I just encountered it deep into a redesign and it's killing me.

@cmpalmer66
Copy link

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.

@programmingworld1
Copy link

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..

@abondarenko
Copy link

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?

@hartez
Copy link
Contributor

hartez commented Oct 26, 2020

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.

@abondarenko
Copy link

I'm using binding and the thing is binded property is empty after a scrolling.

@hartez
Copy link
Contributor

hartez commented Oct 27, 2020

@abondarenko What does your DataTemplate and your Binding look like? Can you post your XAML/code?

@assanesuzy
Copy link

assanesuzy commented Dec 14, 2021

@hartez I am having a problem with this as well in a CarouselView on iOS. we have a picker that get's the SelectedItem cleared when scrolling from the last fragment, the third fragment, to the first, and then back again. The Selected Item is bound to a property using TwoWay binding. Can this be re-opened?

@Fernando-Braulio
Copy link

March 2022 and the problem still occurs, both for IOS and Android

@Fernando-Braulio
Copy link

Unfortunately with CollectionView the error occurs, but it is possible to work around using ListView CachingStrategy="RetainElement"

@Richard-Dufour
Copy link

Dec. 2023 and the problem persists.

@lightwaver
Copy link

No progress... Very sad...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants