I have a xamDataGrid wired up to a data source which can have data rows changed or updated within it. This is all working fine and the grid updates and the data changes.
However to indicate to the user that a row has changed I want to change the style of that row to highlight it (the set it back to normal and highlighting the next row that changes). I assume that I need to apply a style to a particular row but I don't know how to do that - can anyone enlighten me?
Hi,
In answer to your question - "How to highlight a changed(updated) xamDataGrid row and how to restore its previous style(background) after changing(updating) another xamDataGrid row ?" I would suggest the following solution:
1. Use the RecordUpdated event of the xamDataGrid
2. Change the background of the updated(changed) row through using the DataRecordPresenter
DataRecordPresenter.FromRecord((Record)e.Record).Background = Brushes.LightGoldenrodYellow;
3. Keep the DataRecordPresenter reprisenting the updated(changed) record and the updated(changed) record
The attached ChangingRowBackgroundProgrammatically sample application contains the full solution implementation.
Best Regards,Yanko
Hi mkassa,
In answer to your question - "How to preserve the row background after scrolling out of the visible area ?" I would suggest the following solution:
1. Use the Tag property on the DataRecord, so in the RecordUpdated event set the DataRecord.Tag to a Boolean true .2. Place the below-mentioned style in the Window Panel's Resources section.
<Style TargetType="{x:Type igDP:DataRecordPresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=DataRecord.Tag, Converter={StaticResource preserveChangedRowBackground}}" Value="True"> <Setter Property="Background" Value="Goldenrod"/> </DataTrigger> </Style.Triggers></Style>
The attached PreserveChangedRowBackground application sample contains the full solution implementation.