如何更改所选数据网格行的蓝色 [英] How to change the blue color of selected datagrid rows

查看:130
本文介绍了如何更改所选数据网格行的蓝色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗯,我已经看到这个代码:

Well, I have seen this code to do that:

<DataGrid.RowStyle>
    <Style TargetType="DataGridRow">

        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="Black"/>
                <Setter Property="Foreground" Value="Green">
                </Setter>
            </Trigger>
        </Style.Triggers>

        <Setter Property="Background">                        
            <Setter.Value>
                <MultiBinding Converter="{StaticResource ucComponentesColorFilaMultiValueConverter}">
                    <Binding ElementName="dgdComponentes" Path="ItemsSource" />
                    <Binding ElementName="dgdComponentes" Path="SelectedItems" />
                    <Binding ElementName="CurrentItem" />
                </MultiBinding>
            </Setter.Value>
        </Setter>
    </Style>
</DataGrid.RowStyle>

真的代码是风格触发器,setter属性是为其他情况,但我添加代码这可能会影响到结果。

Really the code is the style trigger, the setter property is for other cases, but I add the code of this can affect to the result.

我想更改所选行背景,默认情况下是蓝色,我想根据一些条件要其他颜色。例如,如果添加了一个寄存器,那么如果我选择该行,那么它将是绿色的,如果该行被选中,那么它将是浅绿色。

I would like to change the selected row background, that by default is blue, and I want to other color according to some conditions. For example, if a register is added, then if I select the row it would be green, if this row is unselected, it would be light green.

我是能够根据需要更改行的颜色,但是当我选择它时,始终是蓝色的。

I am be able to change the color of the rows as I want, but when I select it, always is blue.

谢谢。

推荐答案

你可以尝试这样的事情...

You can try something like this maybe...

       <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
       <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />

这篇关于如何更改所选数据网格行的蓝色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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