Hello,
I have my view's XamDataGrid bound to DataTable in my ViewModel. Few columns (E.g. C1, C2) in this grid are editable. Users can change values in those columns (E.g. Row1 C1 changed) and once they hit Submit button, I close the control and open same control again with same data, but want to change the background color of the cell (i.e. Row1 C1) to highlight that this value was modified. The way I thought of doing it is:
1) Once user change the value, in my EditModeEnded event, I get the background DataRow (of DataTable) and in Tag column, I put the column name that was changed (i.e. C1)
2) I pass the same data set again for 2nd time confirmation view opening and want to look at Tag column and highlight all cells that were changed.
Please tell me if this is the right approach of doing it and also a sample code would be beneficial.
Thanks.
var oldValue = e.Cell.Value.ToString(); var newValue = e.Editor.Value.ToString(); if (oldValue != newValue) { CellValuePresenter cvp = CellValuePresenter.FromCell(e.Cell); cvp.Tag = "Changed"; }
<Style TargetType="{x:Type igDP:CellValuePresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" Value="Changed"> <Setter Property="Background" Value="Yellow"/> </DataTrigger> </Style.Triggers> </Style>