How do I conditionally change cell background color

Nov 16, 2009 at 10:08 PM

I found another discussion on this, but the only code sample that I saw used a converter, which from my understanding only works to switch between two cell states. One of the posters suggested using a DataTrigger, but he didn't leave any sample code, so while his idea seemed good, I'm not sure on the implementation.

I'm using the WPF toolkit datagrid, and I'd like to set the background color of a cell, not the row, based on the content of the cell.For the sake of simplicity, lets say the column is called Foo and I'd like the background of the cell to be blue when Foo is 1, red when Foo is 2, Yellow when Foo is 3 and Green when Foo is greater than 3. If I can do that, I'm pretty sure I can solve any of the more complex cases that I need to deal with.

Everything I'm doing seems to change the entire background of the row, not the individual Foo cell that meets my criteria.