DataGrid行的条件文本颜色?

编程入门 行业动态 更新时间:2024-10-28 11:26:54
本文介绍了DataGrid行的条件文本颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个datagrid绑定到一个数据库表。我需要将一行的前色改为蓝色,这取决于其中一列的值。有没有办法我可以做到这一点?我尝试过IValueConverter,但我认为我一次只能使用一个单元格。

解决方案

< DataGrid> < DataGrid.CellStyle> < Style TargetType ={x:Type DataGridCell}> < Style.Triggers> < DataTrigger Binding ={Binding SomeProperty}Value =SomeValue> < Setter Property =ForegroundValue =Blue/> < / DataTrigger> < /Style.Triggers> < / Style> < /DataGrid.CellStyle> < / DataGrid>

I have a datagrid which is bound to a database table. I need to change the forecolor of a row to blue depending on there is a value in one of its columns. Is there a way I can do this? I tried IValueConverter, but I presume I can use this only for one cell at a time.

解决方案

<DataGrid> <DataGrid.CellStyle> <Style TargetType="{x:Type DataGridCell}"> <Style.Triggers> <DataTrigger Binding="{Binding SomeProperty}" Value="SomeValue" > <Setter Property="Foreground" Value="Blue" /> </DataTrigger> </Style.Triggers> </Style> </DataGrid.CellStyle> </DataGrid>

更多推荐

DataGrid行的条件文本颜色?

本文发布于:2023-11-11 10:08:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1578123.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   颜色   条件   DataGrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!