i'd like to change the color of individual rows based on a property in the bound datasource.
Suppose i've got a collection (observable of course) with a few items and each item has a boolean property. The itemssource prop of the datagrid is set to this collection.
I would really like set the color of each row based on the boolean value of each item. Up till now i can't seem to find the solution. I've used rowbackground with a converter, but that only changes each and every row. Anu suggestions?
On a sidenote. The defult backgroundcolor of the rows is defined in a generic.xaml file. When i use a converter to change this color, what do i have to do in the convertback method? Right now i return a null value which causes the rows to set back to some gray
color instead of the one in my generic.xaml.
Meanwhile i'm of to look at the frozenrow sample. Maybe there's a solution for me.
Thanks in advance!
Apparently there is a property called rowstyle, so the answere is as fast as it is simple (thanks to google and a few found posts of others).
With the code below the main issue of the OP is solved. All that remains now is when i uncheck the checkbox, the color of the row doesn't go back to its original color, but it will become a nasty shade of gray.
So i can still use some help on that one.
Currently i return null in the ConvertBack method. I did try to set the mode to oneWay on the background property, did not do any good.
Anyway, here's the simple xaml which i found.
Path=Name}" Header="Naam" MinWidth="110"></wpf:DataGridTextColumn>
Path=IsActive}" Header="Actief" MinWidth="50"></wpf:DataGridCheckBoxColumn>
Mode=oneWay is'nt really necessary here. The name of the converter really should be something like BooleanToBackgroundConverter or something.
well, for problem two, Paul Stovell has a nice solution. He writes about it in http://social.expression.microsoft.com/Forums/en-US/blend/thread/ab5f4a1a-af64-405c-a7b1-1e369c55a767/
Now all i need is someone to translate this solution to my problem. I am using a generic.xaml in which a style for the datagrid is defined.