0

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?

Zubair Akhtar
  • 11
  • 1
  • 6

1 Answers1

4

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.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91