IssueRaiser

Collection<T> and ObservableCollection<T> do not support ranges

# Update 10/04/2018 @ianhays and I discussed this and we agree to add this 6 APIs for now: ```cs // Adds a range to the end of the collection. // Raises CollectionChanged (NotifyCollectionChangedAction.Add) public void AddRange(IEnumerable<T> collection) => InsertItemsRange(0, collection); // Inserts a range // Raises CollectionChanged (NotifyCollectionChangedAction.Add) public void InsertRange(int index, IEnumerable<T> collection) => InsertItemsRange(index, collection); // Removes a range. // Raises CollectionChanged (NotifyCollectionChangedAction.Remove) public void RemoveRange(int index, int count) => RemoveItemsRange(index, count); // Will allow to replace a range with fewer, equal, or more items. // Raises CollectionChanged (NotifyCollectionChangedAction.Replace) public void ReplaceRange(int index, int count, IEnumerable<T> collection) { RemoveItemsRange(index, count); InsertItemsRange(index, collection); } #region virtual methods protected virtual void InsertItemsRange(int index, IEnumerable<T> collection); protected virtual void RemoveItemsRange(int index, int count); #endregion ``` As those are the most commonly used across collection types and the `Predicate` ones can be achieved through Linq and seem like edge cases. To answer @terrajobst questions: > Should the methods be virtual? If no, why not? If yes, how does eventing work and how do derived types work? Yes, we woul

Posted by robertmclaws on Aug 13, 2016, 6:31 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.5,000 issues0 comments

support (Other)

Collection<T> and ObservableCollection<T> do not support ranges

robertmclawsAug 13, 2016, 6:31 AM

# Update 10/04/2018 @ianhays and I discussed this and we agree to add this 6 APIs for now: ```cs // Adds a range to the end of the collection. // Raises CollectionChanged (NotifyCollectionChangedAction.Add) public void AddRange(IEnumerable<T> collection) => InsertItemsRange(0, collection); // Inserts a range // Raises CollectionChanged (NotifyCollectionChangedAction.Add) public void InsertRange(int index, IEnumerable<T> collection) => InsertItemsRange(index, collection); // Removes a range. // Raises CollectionChanged (NotifyCollectionChangedAction.Remove) public void RemoveRange(int index, int count) => RemoveItemsRange(index, count); // Will allow to replace a range with fewer, equal, or more items. // Raises CollectionChanged (NotifyCollectionChangedAction.Replace) public void ReplaceRange(int index, int count, IEnumerable<T> collection) { RemoveItemsRange(index, count); InsertItemsRange(index, collection); } #region virtual methods protected virtual void InsertItemsRange(int index, IEnumerable<T> collection); protected virtual void RemoveItemsRange(int index, int count); #endregion ``` As those are the most commonly used across collection types and the `Predicate` ones can be achieved through Linq and seem like edge cases. To answer @terrajobst questions: > Should the methods be virtual? If no, why not? If yes, how does eventing work and how do derived types work? Yes, we woul

Comments (0)

No comments yet. Start the discussion.

Comment on this issue