List<> collection does not update the View in MVVM

前端 未结 4 1078
闹比i
闹比i 2021-01-15 12:36

I used the List collection as the ItemsSource for the DataGrid control.

But it did not update the View if i remove the item from the List

4条回答
  •  无人及你
    2021-01-15 12:53

    Because the update of a databinding is not a kind of magic, there are several requirements to make databinding working correctly. If you have a single property to bind on this property must be either a dependency property or its parent class must implement the INotifyPropertyChanged interface to notify the wpf binding system about changes of the property value. For a collection there is a simelar mechanism: it must implement INotifyPropertyChanged to inform the wpf binding system about removed/moved/added items.

    See here for more details: http://msdn.microsoft.com/en-us/library/system.collections.specialized.inotifycollectionchanged.aspx

提交回复
热议问题