<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>

以下是仅修改选中行颜色(之前一直修改失败,原因是修改了RowStyle,这个会被CellStyle替换,故需要直接修改CellStyle

<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="MinWidth" Value="85"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="LightBlue"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>

【WPF】通过修改dataGrid的cell的style,改变选中行失去焦点时的颜色的更多相关文章

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

    <Style TargetType="{x:Type DataGridCell}"> <Style.Triggers> <Trigger Proper ...

  2. wpf dataGrid 选中行 失去焦点时 的背景颜色的更改

    关于 wpf dataGrid 选中行 失去焦点时 的背景颜色的更改.很简单的方式,在datagrid的resource中更改InactiveSelectionHighlightBrushKey属性的 ...

  3. Silverlight 查询DataGrid 中匹配项 ,后台改变选中行颜色

    需求:根据关键字(参会人号码或名称)查找参会人,在datagird 中高亮显示 界面:我在界面上增加了一个文本框和按钮,进行查找操作 操作说明: 根据关键字进行搜索:输入关键字 点击查找,如果找到 以 ...

  4. WPF DataGrid ListView 等等 改变 选中行 颜色;以及 不变的原因

    WPF中改变选中行的颜色是很简单的,就是用触发器:比如:以DataGrid为例: DataGrid.RowStyle Style TargetType= DataGridRow SetterPrope ...

  5. 解决IsEditable="True"的ComboBox在DataGrid中点击一次不能选中行的问题

    原文:解决IsEditable="True"的ComboBox在DataGrid中点击一次不能选中行的问题 此方法很笨拙,并不推荐使用!!! 此方法很笨拙,并不推荐使用!!! 此方 ...

  6. WPF中修改DataGrid单元格值并保存

    编辑DataGrid中的单元格的内容然后保存是非常常用的功能.主要涉及到的方法就是DataGrid的CellEditEnding  和BeginningEdit .其中BeginningEdit 是当 ...

  7. JQuery EasyUI DataGrid获取当前行或选中行

    1.获取当前选中行,如果没有选中行,则返回 null var row = $('#gridID').datagrid('getSelected'); 2.获取当前所有选中行数据,返回元素记录的数组数据 ...

  8. WPF 中获取DataGrid 模板列中控件的对像

    WPF 中获取DataGrid 模板列中控件的对像 #region 当前选定行的TextBox获得焦点 /// <summary> /// 当前选定行的TextBox获得焦点 /// &l ...

  9. WPF 控件DataGrid绑定

    WPF 手动绑定 DataGrid 例子:前台:<DataGrid AutoGenerateColumns="False" Name="dataGrid1" ...

随机推荐

  1. Httpd服务进阶知识-LAMP架构概述

    Httpd服务进阶知识-LAMP架构概述  作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.LAMP架构概述 1>.什么是LAM(M)P架构 L: linux A: apa ...

  2. CentOS 7.2搭建FastDFS 分布式文件系统,实现高可用集群

    分布式集群搭建结构 双Tracker 2组Group 轮询存储策略 Keepalived+Nginx高可用 Nginx缓存 4个存储节点 一. 集群规划清单 1.安装清单 软件名称 版本 百度云盘存放 ...

  3. 201671010438王奕晗实验十四 团队项目评审&课程学习总结

    个人学习总结博客 项目 内容 这个作业属于哪个课程 任课教师博客主页链接 这个作业的要求在哪里 作业链接地址 作业学习目标 完成个人软件心得总结 一.结合本学期课程学习内容,对比<实验一 软件工 ...

  4. wordpress不同分类调用不同的模板

    今天网友问ytkah:wordpress不同分类如何调用不同的模板.我们知道in_category() 函数可以通过分类别名或ID判断当前文章所属的分类,而且可以直接在循环(Loop)内部和外部使用. ...

  5. del_deploy.core.prefs.bat

    cd /d "D:\Workspaces\MyEclipse 10" del ".metadata\.plugins\org.eclipse.core.runtime\. ...

  6. Virtual DOM--react

    Consider a DOM made of thousands of divs. Remember, we are modern web developers, our app is very SP ...

  7. Bounding Box回归

    简介 Bounding Box非常重要,在rcnn, fast rcnn, faster rcnn, yolo, r-fcn, ssd,到今年cvpr最新的yolo9000都会用到. 先看图 对于上图 ...

  8. luogu_3645: 雅加达的摩天楼

    雅加达的摩天楼 题意描述: 有\(N\)座摩天楼,从左到右依次编号为\(0\)到\(N-1\). 有\(M\)个信息传递员,编号依次为\(0\)到\(M-1\).编号为i的传递员最初在编号为\(B_i ...

  9. diffy 方便的bug 以及流量测试系统

    diffy 是twiiter 开源的流量以及bug 查找系统 参考使用图 几点说明 使用diffy我们需要三个角色 candidate instance 候选实例,运行新的代码 primary ins ...

  10. 在IDEA编辑器中建立Spring Cloud的子项目包(构建微服务)

    本文介绍在IDEA编辑器中建立Spring Cloud的子项目包 总共分为5个包: 外层使用maven quickstart建立,子modules直接选择了springboot