dirty field

Nov 29, 2008 at 6:22 AM
I'm binding to an ObservableCollection and need a way to know that a cell/row has changed.

My first thought was to use some sort of validation rules.

A previous poster had posted an example where the follow code was used to do row level validation:

                    <dc:RowDummyValidation ValidationStep="UpdatedValue" />

This might work, but I don't know what RowDummyValidation is or how to make it.



Nov 29, 2008 at 6:33 AM
sorry, the xaml code was actually this:

                    <local:RowDummyValidation ValidationStep="UpdatedValue" />

and in the code behind:

        private override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
            return ValidationResult.ValidResult;

Nov 29, 2008 at 7:41 PM

The best way to determine when a row has changed is to detect when the DataGrid commits the change. If your objects implement IEditableObject you can raise an event when the EndEdit methods is invoked by the DataGrid. See this article for details:


Especially the part about layered architectures:


Colin E.

Nov 30, 2008 at 2:07 AM
Hey Colin,

Thanks for getting back. I 've been using your fine article since the very beginning with DataGrid, but in this case, I seem to not be finding what I'm looking for. But I think you gave me an idea ...

The collection bound to the DataGrid implements ObservableCollection which (I think) means it must implement INotifyPropertyChanged.  So each field has a PropertyChangedEventHandler event which I think I can look at.