I have a datagrid, that has as its base an XML file.
Depending on the data in the xml, the list gets sorted.
What i now want to do is change the first 3 lines background color, for example the first one red, second yellow and 3rd blue.
after the 3rd it can all be just default white.
I cant find how to do this, anyone could help me out ?
thanx!
Most simplest way would be to handle the
LoadingRowevent ofDataGridand update the colors inside it.another way could be to retrieve the first three
DataGridRowfromDataGridusing the method described in this post. Then use the dataGridRow’sBackgroundproperty to change it’s colorA more cleaner way would be to define a
styleforDataGridRowand usetriggersto change thebackgroundcolor of particularDataGridRow. I am not sure if you have some criteria behind changingbackgroundcolor of first three rows or it is a hard coded requirement. If it is some criteria or value inDataGridthen you should go forStylebased approach.