Getting notified when collection changes with ObservableCollection in C# .NET
November 9, 2017 1 Comment
Imagine that you’d like to be notified when something is changed in a collection, e.g. an item is added or removed. One possible solution is to use the built-in .NET generic collection type ObservableCollection of T which is located in the System.Collections.ObjectModel namespace. The ObservableCollection object has an event called CollectionChanged. You can hook up an event handler to be notified of the changes.
If you don’t know what events, event handlers and delegates mean then start here.
Let’s see a simple example with a collection of strings: