I want to ask you why we use ObservableCollection Class in Our UWP app?
If we do not use ObservableCollection class what happen with our program?
I want to ask you why we use ObservableCollection Class in Our UWP app?
If we do not use ObservableCollection class what happen with our program?
The main advantage of ObservableCollection
as opposed to classic collections like List
is when you are using data binding with list controls. ObservableCollection
implements the INotifyCollectionChanged
interface and notifies the binding about any change that occurs in the collection.
The CollectionChanged
event handler, and specifically the NotifyCollectionChangedEventArgs
instance provides can inform about all types of item operations - replace, move, add and remove, so the list control can react as expected in each of these situations - like ListView
which can show smooth animations for all of these events.
Any collection which does not implement INotifyPropertyChanged
will still work with all list controls, but will only bind and load the items that are in the collection at the time of binding and any future changes will not be reflected in the control.