wpf工具包datagrid中的条件格式 [英] conditional formatting in wpf toolkit datagrid

查看:136
本文介绍了wpf工具包datagrid中的条件格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我想根据模型中的布尔值更改行前景色,最好的方法是什么?

hey i wanna change row foreground color according to a boolean in the model, whats the best way of doing it?

推荐答案

按以下方式定义样式(IsBlah是布尔型属性):

Define the style as following (IsBlah is a boolian property):

    <Style x:Key="MyRowStyle" TargetType="{x:Type dg:DataGridRow}">
        <Setter Property="Background" Value="White"/>
        <Setter Property="Foreground" Value="DarkBlue"/>            
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsBlah}" Value="False" >
                <Setter Property="Background" Value="DarkGray" />
                <Setter Property="Foreground" Value="White" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

您的DataGrid应该具有自定义的RowStyle。 (RowStyle = {StaticResource MyRowStyle})

Your DataGrid should have a custom RowStyle. (RowStyle="{StaticResource MyRowStyle})

这篇关于wpf工具包datagrid中的条件格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆