Refresh one cell only in DataGrid

Jun 23, 2009 at 2:39 AM

Hi All,


Is it possible to refresh one cell (call GenerateElement() once) of the DataGrid? Now I used NotifyPropertyChanged("ElementStyle") but this will refresh all the rows of the column (Called GenerateElement many times)

Jun 26, 2009 at 7:28 PM

I'm also interested in this. Anybody have a solution?

Jun 26, 2009 at 8:45 PM

Hey tonytam,

What is the actual scenario you are trying to solve. I am afraid it is not possible to do what you are asking for in a non-hacky way (Setting IsEditable to true and then to false on DataGridCell would do the trick, but it is hacky).

Jun 28, 2009 at 8:31 AM

Hi VamseeP,

Thanks for your reply. I will try your hacky-way to see whether it can solve my scenario. And I will let you know the result later.

My scenario is that I extend the DataGridTextColumn and override the method GenerateElement(). Inside this method, I need  to access my own data structures in order to do some UI formattings such as Underline the textblock. Once, my data structure is updated I need to repaint that cell only  (Like calling Invalidate() in WinForm). Now I just call NotifyPropertyChanged("ElementStyle") to repaints the UI but this call will refresh all the rows of the column. The performance is not good when my DataGrid contains many records.