Initialize ObservableCollection<T>
suggest changeObservableCollection is a collection of type T like List<T> which means that it holds objects of type T.
From documentation we read that :
ObservableCollection<T>represents a dynamic data collection that provides notifications when items get added, removed, or when the entire list is refreshed.
The key difference from other collections is that ObservableCollection<T> implements INotifyCollectionChanged and INotifyPropertyChanged, and it raises a notification when an object is added or removed and when the collection is cleared.
This is especially useful for connecting the UI and backend of an application without having to write extra code because when an object is added to or removed from an observable collection, the UI is automatically updated.
The first step in order to use it is to include
using System.Collections.ObjectModel;
You can either create an empty instance of a collection for example of type string
ObservableCollection<string> collection = new ObservableCollection<string>();
or an instance that is filled with data
ObservableCollection<string> collection = new ObservableCollection<string>()
{
"First_String", "Second_String"
};
As in every IList collection, the index starts at 0 (IList.Item Property).