Section147.1:InitializeObservableCollection<T>
ObservableCollectionisacollectionoftypeTlikeList<T>whichmeansthatitholdsobjectsoftypeT. From documentation we read that :
ObservableCollectionrepresentsadynamicdatacollectionthatprovidesnotificationswhenitemsget added, removed, or when the entire list is refreshed.
The key difference from other collections is that ObservableCollectionimplements the interfaces INotifyCollectionChangedandINotifyPropertyChangedandimmediatelyraisenotificationeventwhenanew objectisaddedorremovedandwhencollectioniscleared.
This is especially useful for conneting 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.
Thefirststepinordertouseitistoinclude
usingSystem.Collections.ObjectModel
Youcaneithercreateanemptyinstanceofacollectionforexampleoftypestring
ObservableCollection<string>collection=newObservableCollection<string>();
oraninstancethatisfilledwithdata
ObservableCollection<string>collection=newObservableCollection<string>()
{
“First_String”,”Second_String”
};
RememberasinallIListcollection,indexstartsfrom0(IList.ItemProperty).
About us and this blog
We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.
Request a free quote
We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.
Subscribe to our newsletter!
More from our blog
See all postsRecent Posts
- Chapter155:Interoperability 24/06/2024
- Chapter154:RuntimeCompile 23/06/2024
- Chapter153:C#Script 22/06/2024