Hi there,
I'm using your ObservableItemCollection<T> and I have two issues with it. (v. 2012.2.607.40)
First, there's no constructor that takes an IEnumerable<T> or List<T> like the System.Collections.ObjectModel version it eventually inherits from. Though not a requirement, this is very useful for initializing a collection before doing anything else to it.
Secondly (and most importantly) there doesn't appear to be support for adding null items. I get a NullReferenceException when calling:
The code is probably connecting to the item's PropertyChanged event, but a simple check for null during add/remove would allow support for null items.
I've extended the class to support the constructors, but I don't know overloading OnCollectionChanged or some other method will solve my issue. If so, please let me know what this method should contain.
On a slightly different topic, are the Suspend/Resume Notification methods called automatically on AddRange, InsertRange, and RemoveRange? Or do they need to be explicitly called?
Thanks!
I'm using your ObservableItemCollection<T> and I have two issues with it. (v. 2012.2.607.40)
First, there's no constructor that takes an IEnumerable<T> or List<T> like the System.Collections.ObjectModel version it eventually inherits from. Though not a requirement, this is very useful for initializing a collection before doing anything else to it.
Secondly (and most importantly) there doesn't appear to be support for adding null items. I get a NullReferenceException when calling:
collection.Add(
null
);
The code is probably connecting to the item's PropertyChanged event, but a simple check for null during add/remove would allow support for null items.
I've extended the class to support the constructors, but I don't know overloading OnCollectionChanged or some other method will solve my issue. If so, please let me know what this method should contain.
On a slightly different topic, are the Suspend/Resume Notification methods called automatically on AddRange, InsertRange, and RemoveRange? Or do they need to be explicitly called?
Thanks!