WPF - How do I set certain rows in a DataGrid to a different color?
I have a DataGrid. After I set the DataContext property to the source of my data, I would like to programatically (C#) set the color of certain rows to say red if data开发者_Python百科 in the row meets a certain condition. How can I do this?
If you're using the MVVM pattern and you have a ViewModel object representing each row in the DataGrid then I'd expose either a property of type Color
on the ViewModel, or a property in conjunction with a ValueConverter which changes the value of the property (of whatever type) to a Color
.
精彩评论