开发者

WPF - How do I set certain rows in a DataGrid to a different color?

开发者 https://www.devze.com 2023-02-08 04:12 出处:网络
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 meet

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消