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 in the row meets a certain condition. How can I do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
Coloron the ViewModel, or a property in conjunction with a ValueConverter which changes the value of the property (of whatever type) to aColor.