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

Range actions are not supported Exception #1

Open
milos12345 opened this issue May 6, 2020 · 1 comment
Open

Range actions are not supported Exception #1

milos12345 opened this issue May 6, 2020 · 1 comment

Comments

@milos12345
Copy link

milos12345 commented May 6, 2020

I replaced my ObservableCollection with this one and I get

System.NotSupportedException: 'Range actions are not supported.'

on line

OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, changedItems, startIndex));

Using WPF and .NET 4.8. Am I missing something?

Edit: more info:

Stack Trace

at System.Windows.Data.ListCollectionView.ValidateCollectionChangedEventArgs(NotifyCollectionChangedEventArgs e)
at System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Collections.ObjectModel.ObservableCollection1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.RangedObservableCollection1.AddRange(IEnumerable`1 collection) in D:...\RangedObservableCollection.cs:line

when I try

List<object> templist = new List<object>();
...
FilesCollection.AddRange(templist);
@PieterjanDeClippel
Copy link

PieterjanDeClippel commented Jun 28, 2020

I've been able to fix this like this: MintPlayer/MintPlayer.Dotnet.Tools@3c4a0ea

Basically, you cannot call OnCollectionChanged because that would trigger a Range operation.

What you can do instead is loop through all handlers. If the handler is bound from a CollectionView, you can just call the Refresh() method on the CollectionView. Otherwise you can just invoke the handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants