-
Notifications
You must be signed in to change notification settings - Fork 2k
Potential off-by-one error when using ScrollTo in CollectionView with a header. #18389
Copy link
Copy link
Closed
Labels
area-controls-collectionviewCollectionView, CarouselView, IndicatorViewCollectionView, CarouselView, IndicatorViewdelighter-scpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaborationplatform/androids/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Milestone
Description
Metadata
Metadata
Assignees
Labels
area-controls-collectionviewCollectionView, CarouselView, IndicatorViewCollectionView, CarouselView, IndicatorViewdelighter-scpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaborationplatform/androids/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for issues without a type.
Description
Programatically scrolling to the
Count - 1item index (ie the last item in the CollectionView) in a CollectionView using theScrollTomethod does not work when a header is present and instead scrolls to the second-to-last item. I would expect it to scroll to the last item in the CollectionView instead since the documentation states that items in a CollectionView are 0-indexed here is the link where the documentation says thisAs a workaround, scrolling to index
Countdoes scroll to the last item in the CollectionView.Here's a recording demonstrating the behaviour and I also have a public repo with my reproduction code:
collectionview-scrollto-bug.webm
(Note I don't know the .NET version this is happening on, sorry! my
dotnet workload listoutput is below and says I have .NET 8 installed but theTargetFrameworkin my .csproj file isnet7.0)Steps to Reproduce
x:Nameattribute to the CollectionView so it can be referenced in the code-behind<CollectionView Name>.ScrollTo(<CollectionView items name>.Count - 1);The CollectionView will now scroll to the second-to-last item rather than the last item.
Link to public reproduction project repository
https://github.com/bellascalzi1/MauiCollectionViewScrollTo
Version with bug
Unknown/Other
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
I can see this issue in API 33
Did you find any workaround?
If you want to scroll to the last item use
ScrollTo(Items.Count)instead for now.Relevant log output
No response