Skip to content

System.IndexOutOfRangeException when scrolling CollectionView with image CarouselView #31680

@Goncalo-Domingos

Description

@Goncalo-Domingos

Description

When using a CollectionView where each item contains a CarouselView displaying a gallery of images, scrolling the CollectionView sometimes triggers a crash with the following exception:

System.IndexOutOfRangeException: 'Can't set CarouselView to position -1. ItemsSource has 3 items.'
If im doing something wrong please point that out

Steps to Reproduce

Steps to Reproduce:

Create a CollectionView with a complex ItemTemplate where each item contains a CarouselView showing images.

Set the CarouselView.ItemsSource to a small image collection (e.g., 3 images).

Scroll the CollectionView vertically.

Occasionally, the app crashes with the above exception.

Expected Behavior:
Scrolling the CollectionView should not cause CarouselView to attempt to set an invalid position. The CarouselView should handle item recycling safely and never set a position less than 0 or greater than ItemsSource.Count - 1.

Link to public reproduction project repository

https://github.com/Goncalo-Domingos/CollectionThrowsWithCarouselInside

Version with bug

9.0.100 SR10

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android 15 Emulator

Did you find any workaround?

Change the component entirely, install this nugget https://github.com/microspaze/CarouselView.Maui or create one of my own with the platform espefic components

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-collectionviewCollectionView, CarouselView, IndicatorViewpartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/androids/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions