I’m trying to implement change notification on the RowState property of a DataRow object.
Here’s what I have so far, but my SetModified method never gets called:
internal class DataRowEx : DataRow, INotifyPropertyChanged
{
#region Events
public event PropertyChangedEventHandler PropertyChanged;
#endregion
#region Construction
public DataRowEx(DataRowBuilder builder)
: base(builder)
{ }
#endregion
#region Overrides
protected new void SetModified()
{
base.SetModified();
PropertyChanged(this, new PropertyChangedEventArgs("RowState"));
}
#endregion
}
I suppose I could make it internal and call it myself from the object containing the row, but I feel like there should be a better way.
The
DataTableworks withDataRowand, as such, will never call yourSetModified()inDataRowEx(it “hides” the inherited member, it doesn’t override it).Probably the easiest way of achieving what you want is to also implement a custom
DataTable, override eitherOnRowChanging()orOnRowChanged(), and delegate to custom functionality in yourDataRowExfrom there.