wpf的datagrid列选中后改变颜色

wpf的datagrid列选中后改变颜色

<UserControl.Resources>
       <Style x:Key="CellStyle" TargetType="{x:Type DataGridCell}">
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="Transparent" />
                    <Setter Property="Foreground" Value="Black"/>
                    <!--<Setter Property="BorderThickness" Value="0,0,0,0"/>-->
                    <Setter Property="BorderBrush" Value="Transparent"/>
                </Trigger>
                <!--<Trigger Property="DataGridRow.IsFocused" Value="True">
                    <Setter Property="Background" Value="Red" />
                </Trigger>-->
            </Style.Triggers>
        </Style>
        <Style x:Key="CellStyle2" TargetType="{x:Type DataGridCell}">
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="Yellow" />
                    <Setter Property="Foreground" Value="Black"/>

                </Trigger>
                <Trigger Property="DataGridRow.IsFocused" Value="True">
                    <Setter Property="Background" Value="Red" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

你可能感兴趣的:(WPF)