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

CollectionView with Header Causes ArgumentOutOfRangeException on reordering to last index #18227

Open
sylac opened this issue Oct 21, 2023 · 3 comments
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView delighter-sc platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@sylac
Copy link

sylac commented Oct 21, 2023

Description

When using item reordering in CollectionView (#3768) with a defined Header, I encounter an ArgumentOutOfRangeException when attempting to move an item to the last position of the list. This issue is not present when the Header is omitted.

System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than or equal to the size of the collection. (Parameter 'index')'

Steps to Reproduce

  1. Create default MAUI project
  2. Define a CollectionView with a Header and ItemTemplate to xaml file:
<CollectionView
    x:Name="TestCollectionView"
    CanReorderItems="True"
    CanMixGroups="True">

    <CollectionView.Header>
        <Label Text="Header"/>
    </CollectionView.Header>
    
    <CollectionView.ItemTemplate>
        <DataTemplate>
            <Label Text="{Binding .}"/>
        </DataTemplate>
    </CollectionView.ItemTemplate>
</CollectionView>
  1. Populate ItemSource in xaml.cs file:
public TestCollectionViewPage()
{
    InitializeComponent();
    TestCollectionView.ItemsSource = new List<string>()
    {
        "Test label 1",
        "Test label 2",
        "Test label 3",
        "Test label 4",
        "Test label 5",
        "Test label 6",
    };
}
  1. Drag random Item from the middle to last position in the list

Link to public reproduction project repository

No response

Version with bug

7.0.96

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

No response

Did you find any workaround?

No response

Relevant log output

No response

@sylac sylac added the t/bug Something isn't working label Oct 21, 2023
@jsuarezruiz jsuarezruiz added area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/android 🤖 labels Oct 23, 2023
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Oct 23, 2023
@ghost
Copy link

ghost commented Oct 23, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Oct 24, 2023
@XamlTest
Copy link

Verified this on Visual Studio Enterprise 17.8.0 Preview 4.0(8.0.0-rc.2.9373). Repro on Android 13.0-API33, not repro on iOS 16.4 with below Project:
18227.zip

image

@vitalii-vov
Copy link

vitalii-vov commented Oct 27, 2023

Duplicate of #17823
The problem is that on Android, if you add an element to the list header, the index of the list increases by 1.
I did a PR #17825 about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView delighter-sc platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants