I have recently bought a book called "The c# programming language" 4th edition. On page 49 there is a reference to a List having a changed event that can be bound to as an example of events. Have tried to reproduce this but ended up doing some head scratching with this :-
List<string> names = new List<string>();
names.Changed+= new EventHandler(ListChanged);
and so it continues.... Am I missing something or does List not have a changed event?
No, List<T>
doesn't have such event, you are not missing anything. You may checkout the ObservableCollection<T>
which has a CollectionChanged
event you could subscribe to. It is extensively used in WPF and Silverlight to implement the MVVM pattern.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With