DataGridCell value/content update?

Apr 14, 2009 at 4:37 PM


I looked all over for a DataGridCell value/content update event but I could not find it; is there such thing? What I’m trying to achieve is to set the background of a cell that is update through binding, this means that I will not have any BeginEdit and EndEdit event, but I will like to have the similar effect, something like OnPreviewValueChanged  to set the background to red, and OnValueChanged to set back the old background. Any help on this will be much appreciated. Thank you.

Apr 14, 2009 at 8:21 PM
Hi john4ani,

DataGridCell does not have a value changed/updated event.  If I understand your scenario correctly, it sounds like you want to change the background of a cell when the data in that cell is updated in the data source (or in the ViewModel).  To do this, you will need to have some logic built into your app which will determine when the data was updated - for example, you need to compare the data to its old value and see if it has been updated, then store this data in a property.  Once you have that property, you can use a Trigger or Binding.UpdateTargetNotifications to change the background.  This unfortunately may not be a simple thing to do.  Another option is to listen to INotifyPropertyChanged (assuming that your ViewModel implements INotifyPropertyChanged) and then you can manually update the background as needed.

Apr 15, 2009 at 12:49 PM

Hi Samantha,


I have build all the logic, I know when the values are updating, what I don’t know is for what cell is that value, as my grid is a dynamic grid, I create the columns in the code behind because I need to keep a specific format and the row are determinate by the number of records in my data source.


Anyway, I found the answer in this thread: . I set the NotifyOnTargetUpdated to true when I want to have the notification and then use Binding.AddTargetUpdatedHandler to add a event handler that deals with the cell updates.


Thank you for your support,