|
Enhanced C#
Loyc library documentation
|
Encapsulates a ListChanged event that notifies listeners that a list has changed, such as when items are added or removed or the whole list is refreshed. More...
Encapsulates a ListChanged event that notifies listeners that a list has changed, such as when items are added or removed or the whole list is refreshed.
| T | Type of items in the list |
| TCollection | Type of the first argument of the event |
This approach to change notification is more lightweight than the standard INotifyCollectionChanged interface because that interface sends both a list of new items and a list of old items, so many changes require a pair of temporary objects to be created that hold the two lists of items.
In contrast, the ListChanged event includes only one list that specifies the set of new items. No list of old items is provided.
An optimization is available when only a single item is being added or changed. In that case, the collection class should create a lightweight read-only single-item list by calling ListExt.Single{T}(T). Such a list has less overhead than List{T} and the same overhead as an array of one item.
Events | |
| ListChangingHandler< T, TCollection > | ListChanged |
| Occurs when the collection associated with this interface has changed. More... | |
| ListChangingHandler<T, TCollection> Loyc.Collections.INotifyListChanged< T, TCollection >.ListChanged |
Occurs when the collection associated with this interface has changed.
The event handler receives a ListChangeInfo{T} argument, which describes the change.
The event handler should not modify the list that is changing while it is handling the event, because there may be other event handlers that have not received the event; if you modify the collection, more ListChanged events will occur before the initial event is over, which could cause other handlers to receive notifications in the wrong order. Event handlers should not throw: other event handlers attached to the same event will not receive the change notification, and the collection will not revert to its old state.
1.8.7