I used the List
as the ItemsSource for the DataGrid control.
But it did not update the View if i remove the item from the List
ObservableCollectionList
doesn't. That's the reason.
DataBinding is lazy. If you don't tell your view that something has changed, it won't bother updating. Under the hoods, WPF DataBinding registers for change notifications, so that your ViewModel can tell the view when it has changed. It does this with interfaces like INotifyPropertyChanged
and INotifyCollectionChanged
.
ObservableCollection
implements the interface INotifyCollectionChanged. This interface defines the event CollectionChanged, which your View basically attaches its own event handler to. That handler will update the view when the event is raised by the collection.