Is there a way to highlight changed rows in the datagrid? Ie by binding the foreground brush (using a converter) to the state of the underlying DataRow?
Thanks
I found this:
http://forums.infragistics.com/forums/p/2701/16506.aspx#16506
And adapted the idea. But it only seems to re-evaluate when a row scrolls into view, not when leaving edit mode.
How can I get the converted to be called every time the active record changes?
I have also tried maintaining a dictionary of primary keys that have been edited. My valueconverter then looks for the current record's pk in the list, and returns Brushes.Red if it's there, otherwise Brushes.Black. When I save to the db the dictionary is cleared.
This ALMOST works but not quite. I have to scroll so that the edited record is out of sight, then scroll it back into view, to make it go red!
Help!
I also have the same problem and can't seem to find anything in the docs to describe how to do this. I've added an event handler for the RecordUpdated event on the xamDataGrid. In the event handler, I'm successfully able to set the value of other columns in the updated row, but I would suspect some way to also set the row color, font, etc. This seems like a "no-brainer", but still no luck after several hours research.
Hi Steve,
Have you considered handling the EditModeEnding event in the xamDataGrid? The EditModeEndingEventArgs parameter for this event contains the Editor which loses EditMode focus when the user finishes editing the element and will allow you to AcceptChanges or reject them. With access to the editor I can do things like change the BorderBrush for the editor.
This may prove to be one possible approach.
e.Editor will just be the single cell, won't it?
I wanted to highlight the whole row - I was adding the primary key in the RecordUpdated event, ie when the edit gets posted back to the underlying datasource.
EditModeEndingEventArgs also has a Cell property. With the Cell, you can get information about the row such as the row index:
e.Cell.DataPresenter.ActiveRecord.Index
Actually I want to set the cell border of the record BELOW the edited cell to change color.
The [0] index record contains a Billing Rate for an employee. This billing rate can be changed by the user. I use XamNumericEditor for these updatable fields.
The [1] index record contains a calculated Effective Multiplier based on the billing rate divided by the actual pay rate. This record cannot be updated by the user. I use XamNumericEditor for these fields, even though they cannot be updated, for the benefit the XamNumericEditor gives me in formating the presentation of values.
When the [0] index record billing rate is changed the [1] index record caculated field changes. If this calculated value is below a threshold value I want the field border to change color on the [1] index record, not the [0] index record that was actually updated.
I have not been able get a reference to the [1] index record cell editor from inside the [0] index record EditModeEnding event.
A complicated explanantion for a simple issue to resolve I hope.
Are you saying that you want to set the border for the selected cell and the cell directly below it in the next record?
You solution to highlight the changed cell works great for me. Of course I need to to do more and also want it to highlight the cell editor border of the cell below. This specific grid contains static data and changing the value of one cell causes a calculation be performed and displayed in the cell of the DataRecord below the DataRecord being changed.
Here is my code from EditModeEnded. After the user updates the cell in DataRecord[3], I am attempting to reference the cell in DataRecord[4] at the corresponding index - multCell. I cannot get a reference to the Editor of multCell, I can get DataPresenter, EditorStyle, Field, Record but have not found a path to the cells Editor to set its Border color. The properties I can get a hold of change the settings for every cell in the grid or lead me back to the cell.
if (effMult < (decimal)2.9)
e.Editor.BorderBrush = Brushes.Red;
}
Thanks for your help.
Hi Robert,
You can either explicitly change the brush in an event handler. Or you can keep a reference to a dynamic brush resource. Changing the brush in your code will cause the brush to update in the UI. The XamDataGrid takes advantage of WPF features such as DynamicResources.
Let me know if you need further clarification.
Thanks!
John said:
Using a CellValuePresenter style, and a converter to go from DataRecord to Brush seems the best way..
But how to we invalidate / repaint the row (to force the cellvaluepresenter to reevaluate the brush)?
I am looking forward to hearing the answer to the problem of forcing a reevaluation of the brush. Someone in another thread suggested toggling the record visibility from collapsed to visible, but this causes a crash in my application. Would you be so kind as to answer this question? Many thanks.
Robert Brower