Need a collection class with events

I need a collection class in C # that fires an event when I add or remove an item. Is there such a collection class?

+3
source share
4 answers

ObservableCollection<T>should work in most cases. It implements INotifyCollectionChanged, which is an interface that:

Notifies listeners of dynamic changes, for example, when items are added and removed, or the entire list is updated.

+7
source

You can take a look at the class ObservableCollection, it has events for CollectionChanged, which handles when an item is added, deleted, changed, moved or the entire list is updated.

+2
source

System.Collections.ObjectModel.ObservableCollection INotifyCollectionChanged, , , . , .NET 4 WPF.

You can always implement it INotifyCollectionChangedyourself.

+2
source

In addition ObervableCollection, there is a second possible candidate BindingList<T>.

0
source

All Articles