如何将数据网格行的背景绑定到特定颜色?
我有一个绑定到数据网格的可观察集合。我在视图模型中还有一个颜色属性,我想将数据网格中每一行的背景绑定到虚拟机上的颜色属性。
I have a observable collection that binds to a data grid. I also have in the view model a color property and I want to bind the background of each row in the data grid to the color property on the vm.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在
RowStyle
中为DataGrid
绑定Background
如果
MyBackground
是Brush< /代码>。您在问题中提到您有一个
Color
,如果是这种情况,您可以使用它You can bind the
Background
in theRowStyle
forDataGrid
This will work if
MyBackground
is aBrush
. You mention in your question that you have aColor
, if this is the case you can use this instead