-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Improved INotifyCollectionChanged Handling #52
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
Comments
Yes! This has been extremely annoying. Being able to trigger one large change for a set of items without causing UI relayout over and over again would be a huge perf improvement. The interface completely supports this, but for some reason WPF never has. Currently our only choice is to trigger a reset event, which causes a complete relayout of all items. |
The following apis have been approved for public partial class Collection<T>
{
public void AddRange(IEnumerable<T> collection);
public void InsertRange(int index, IEnumerable<T> collection);
public void RemoveRange(int index, int count);
public void ReplaceRange(int index, int count, IEnumerable<T> collection);
// These are override by ObservableCollection<T> to raise the event:
protected virtual void InsertItemsRange(int index, IEnumerable<T> collection);
protected virtual void RemoveItemsRange(int index, int count);
protected virtual void ReplaceItemsRange(int index, int count, IEnumerable<T> collection);
} |
This isn't about ObservableCollection, but about INotifyCollectionChanged interface. Any collection can implement that interface and have add-range, or be adding items in "chunks" (like incrementally loading datasources etc) |
I was under the impression that it's "just" Admittedly, however, I haven't tried it... am I mistaken? Edit: that said, |
Could be a 6.0.0 candidate? This currently blocks the range support in .net 6 ObservableCollection |
In this context, I would like to point out the following problem: wpf/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/EnumerableCollectionView.cs Line 423 in 026f338
In this case, the entire CollectionView would have to be reloaded. |
This is one of the top-requested features in all of the world of .NET, going back many years. Offering this is crucial. |
Suggestion: We don't we log an issue for each control that have a problem with multi-item changes, and that way we can start chipping away at it and hopefully get to a point where we can add |
This is a carry over from .NET Framework.
If INotifyCollectionChanged.CollectionChanged -> NotifyCollectionChangedEventArgs.NewItems has more than one item, most WPF controls will throw an exception.
The main reason for this original design is that ObservableCollection doesn't have an AddRange method and the controls assum that nothing else will support INotifyCollectionChanged.
The text was updated successfully, but these errors were encountered: