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

Fixes IObservableVector based ItemsSource exception #4360

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

w-ahmad
Copy link

@w-ahmad w-ahmad commented Nov 2, 2021

Fixes #4263 and #2913

PR Type

What kind of change does this PR introduce?

Bugfix

What is the current behavior?

What is the new behavior?

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • New component
    • Pull Request has been submitted to the documentation repository instructions. Link:
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
    • If control, added to Visual Studio Design project
  • Sample in sample app has been added / updated (for bug fixes / features)
  • New major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

@ghost
Copy link

ghost commented Nov 2, 2021

Thanks w-libs for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested review from michael-hawker and azchohfi November 2, 2021 13:15
@ghost ghost added bug 🐛 An unexpected issue that highlights incorrect behavior DataGrid 🔠 Issues on DataGrid control labels Nov 2, 2021
@ghost
Copy link

ghost commented Nov 2, 2021

This PR has been marked as "needs attention 👋" and awaiting a response from the team.

Copy link
Contributor

@XAML-Knight XAML-Knight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Approved. Confirmed fix for #4263. Seems to fix #2913, but could not repro the bug in that issue.

@michael-hawker
Copy link
Member

@Arlodotexe this should be a good quick one to review too. Let me know your thoughts.

@SeRgI1982
Copy link

Hi guys,

When you plan apply this fix ?

DataGrid is unusable when you use CollectionViewSource and would like to manipulate data which are bounded under the hood.

My case:

Items has for ex. 10 elements.

ObservableCollection<Item> items = GetItems();
CollectionViewSource source = new CollectionViewSource
{
           IsSourceGrouped = false,
           Source = items
}; 

DataGrid.ItemsSource = source.View;

I am removing items in that way:

private void RemoveItem(Item itemToRemove)
{
    if (source is ObservableCollection<Item> items)
    {
        if (items.Contains(itemToRemove)
        {
            items.Remove(itemToRemove);
        }
    }
}

or

private void RemoveItem(Item itemToRemove)
{
    if (source.View.Contains(itemToRemove)
    {
        source.View.Remove(itemToRemove);
    }
}

When I will try to remove random item but not the last one - everything is ok.
When I will try to remove the last one - System.ArgumentOutOfRangeException happens.

Is there a chance to put the fix to the next release ?
The fix waiting for merge over almost 1.5 years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior DataGrid 🔠 Issues on DataGrid control
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AdvancedCollectionView ArgumentOutOfRangeException when remove the last element
4 participants