How are WPF observable collections different from simple .NET collections? (.NET WPF Interview questions)
- By Shiv Prasad Koirala in .Net
- Mar 26th, 2014
- 9308
- 0
If you are preparing for WPF interviews do not forget to download WPF Interview questions with answer book PDF from here.
Simple .NET collections do not notify the UI automatically when elements are added or removed from them. So when we update simple .NET collection's we need to send refresh events back to the WPF UI for rebinding the collection.
"ObservableCollection" are specialized collection which updates the UI automatically and immediately when new elements are added and removed from the collection.
"ObservableCollection" implement's "INotifyCollectionChanged "interface. This interface exposes "CollectionChanged" event which gets raised when elements are added or removed to the collection.
Below is a simple code which creates "ObservableCollection" collection which is binded with a list.
ObservableCollection<Person>
person = new ObservableCollection<Person>();
lstNames.ItemsSource = person;
Below is one more important WPF Interview questions which is asked in all WPF interviews as the first question. Below is an awesome youtube video which answers this question in more detail.
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more