Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] CollectionView ItemSource bound to ObservableCollection not updating on collection update #2045

Closed
antigones opened this issue Aug 11, 2021 · 4 comments
Assignees
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView p/2 Work that is important, but is currently not scheduled for release s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Milestone

Comments

@antigones
Copy link

Description

A CollectionView ItemsSource is bound to an ObservableCollection.
The ObservableCollection is populated with an async call to an endpoint on application start.
Adding items in the collection is not reflected in the UI.

Steps to Reproduce

  1. Bind a CollectionView ItemsSource to an ObservableCollection
  2. Populate the collection with a call to an endpoint on ViewModel creation
  3. CollectionView in the UI is not displayed
  4. Scroll the CollectionView and the CollectionView items are displayed

Expected Behavior

CollectionView updating according to the underlying ObservableCollection when the application starts.

Actual Behavior

CollectionView does not update according to the underlying ObservableCollection.
If the user scrolls the view in the emulator or the physical device, the CollectionView is correctly displayed.

Basic Information

  • Version with issue: Maui Preview 6

  • Last known good version: N/A (code works with Xamarin.Forms)

  • IDE: Visual Studio 2022 (Version 17.0.0 Preview 2.1)

  • Platform Target Frameworks:

    • iOS: N/A
    • Android: 9.0
    • UWP: N/A
  • Affected Devices: emulator and physical device

Reproduction Link

https://github.com/antigones/MAUI-ToDoApp

Workaround

After fetching the items and adding them to the underlying ObservableCollection, simulate user scrolling CollectionView with:

_cvToUpdate.ScrollTo(1);
_cvToUpdate.ScrollTo(0);

where _cvToUpdate is the CollectionView.

@RyanMelenaNoesis
Copy link

RyanMelenaNoesis commented Aug 26, 2021

I'm seeing this behavior with Maui Preview 7 as well.

Strangely, the CollectionView updates as expected if it is the root element in the page but not when nested inside another element like a GridLayout or StackLayout.

@jsuarezruiz jsuarezruiz added t/bug Something isn't working area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Oct 22, 2021
@jsuarezruiz jsuarezruiz added this to New in Triage via automation Oct 22, 2021
@meilleur102
Copy link

See the same thing on preview 10.
I have a ObservableCollection
When I Add a new Item to the ObservableCollection everything work fine.
When I modify an Item that already exit the UI dont update.

Let me know if you want me to open a Issus on this.
Thanks

@hartez hartez self-assigned this Nov 17, 2021
@shimingsg
Copy link
Collaborator

shimingsg commented Mar 3, 2022

verified with VS 17.2.0 Preview 2.0 [32228.609.main] on Windows and Android:
Windows: not repro
Android: repro

repro demo:
2045.zip

@shimingsg shimingsg added the s/verified Verified / Reproducible Issue ready for Engineering Triage label Mar 3, 2022
@rmarinho rmarinho added this to the 6.0.300 milestone Mar 23, 2022
@davidortinau davidortinau added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Apr 27, 2022
@Redth Redth added p/2 Work that is important, but is currently not scheduled for release and removed p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint labels May 3, 2022
@samhouts samhouts modified the milestones: 6.0.300, 6.0.300-servicing May 7, 2022
@VincentBu
Copy link

In 32506.368.main, I tried shimingsg's project and it worked properly on Windows and Android.

Triage automation moved this from New to Done May 7, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jun 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView p/2 Work that is important, but is currently not scheduled for release s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
No open projects
Development

No branches or pull requests