The datagrid would be bound to a list of objects. If you want the grid to update when individual object properties change, than each contained object must implement the INotifyPropertyChanged
interface.
The INotifyCollectionChanged
is an interface that the collection should implement, and are for notifications of addition and removal events.
See the section "How to implement collections" on this page.
Here's a way to approach your problem:
- Create a new class that exposes the properties currently held in each
DataRow
. On this class implement INotifyPropertyChanged
.
- Instead of a
DataTable
, use an ObservableCollection<T>
or your new class.
ObservableCollection
already implements INotifyCollectionChanged
, so this saves you the effort of implementing it yourself.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…