码迷,mamicode.com
首页 > Windows程序 > 详细

WPF,通过修改dataGrid的cell的style,改变选中行失去焦点时的颜色 4.0可用

时间:2017-12-16 17:11:05      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:选中   post   get   sys   pos   resource   self   for   oar   

        <Style  TargetType="{x:Type DataGridCell}">
            <Style.Triggers>
                <Trigger  Property="IsSelected" Value="true">
                    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
                    <Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                </Trigger>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True" />
                        <Condition Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}, Mode=FindAncestor}}" Value="False" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
                    <Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>

 

WPF,通过修改dataGrid的cell的style,改变选中行失去焦点时的颜色 4.0可用

标签:选中   post   get   sys   pos   resource   self   for   oar   

原文地址:http://www.cnblogs.com/nocanstillbb/p/8046713.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!