主要通过设置DataGrid的RowStyle和CellStyle即可。

             <Style TargetType="DataGridRow" x:Key="gridRowStyle">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="LightGray"/>
</Trigger>
</Style.Triggers>
</Style> <Style TargetType="DataGridCell" x:Key="gridCellStyle">
<!--文字居中-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<!--被选中时,背景色改变-->
<Style.Triggers>
<Trigger Property="DataGridCell.IsSelected" Value="True">
<Setter Property="Background" Value="Gray" />
</Trigger>
</Style.Triggers>
</Style>
       <DataGrid ScrollViewer.CanContentScroll="False" AutoGenerateColumns="False" CanUserAddRows="False"
             CellStyle="{StaticResource gridCellStyle}"
                      RowStyle="{StaticResource gridRowStyle}" />

WPF 改变Datagrid的选中行的颜色的更多相关文章

  1. listview改变选中行字体颜色

    [android]listview改变选中行字体颜色 目标:选中item,其字体设置为#3197FF,未选中的,其字体为#FFFFFF 与listvew设置选中行item背景图片一样,使用select ...

  2. easyui datagrid 禁止选中行 EF的增删改查(转载) C# 获取用户IP地址(转载) MVC EF 执行SQL语句(转载) 在EF中执行SQL语句(转载) EF中使用SQL语句或存储过程 .net MVC使用Session验证用户登录 PowerDesigner 参照完整性约束(转载)

    easyui datagrid 禁止选中行   没有找到可以直接禁止的属性,但是找到两个间接禁止的方式. 方式一: //onClickRow: function (rowIndex, rowData) ...

  3. DEV GridControl.TableView FocusedRow选中行背景颜色

    上次修改了TableView.RowStyle,导致了一个问题:覆盖了GridControl默认的选中行颜色. 于是需要重写选中行的颜色. 刚开始的想法是: <dxg:TableView> ...

  4. EasyUi DataGrid 获取选中行的checkbox

    EasyUi DataGrid 获取选中行的checkbox var checked = $(":checkbox[name=ID]:checked"); console.log( ...

  5. easy ui datagrid 获取选中行的数据

    取得选中行数据: var row = $('#tt').datagrid('getSelected'); if (row){ alert('Item ID:'+row.itemid+" Pr ...

  6. [Irving] Wpf DevexPress GridControl 获取选中行

    WPF前台绑定事件代码: <RelayAction TargetControl="{Binding ElementName=GCInstoragePart}" MethodN ...

  7. easyui datagrid 禁止选中行

    没有找到可以直接禁止的属性,但是找到两个间接禁止的方式. 方式一: //onClickRow: function (rowIndex, rowData) {     // $(this).datagr ...

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

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

  9. datagrid如何获取选中行的索引

    //datagrid获取选中行 var row =baseSelectgrid.datagrid('getSelected'); // 获取被选中行的索引 index var index=baseSe ...

随机推荐

  1. ios runtime简单实用(添加动态属性)

    #import "Person.h" @interface Person (PersonCategory)   // 添加Person中没有的name属性 @property (n ...

  2. mysql基本的增删改查和条件语句

    增 insert into 表名(列名,列名......) values("test1",23),("test2",23),("test3" ...

  3. [leetcode]146. LRU CacheLRU缓存

    Design and implement a data structure for Least Recently Used (LRU) cache. It should support the fol ...

  4. [Meteor] meteor project structure

  5. 品味性能之道<四>:管理重于技术

      一.性能优化中的角色分工 (1).老外的角色分工         在oracle性能优化方法论中,将IT系统中不同角色需要承担的性能优化工作罗列如下. 各司其职的角色分工 业务分析人员 1.业务需 ...

  6. [Selenium]如何实现上传本地文件

    public void uploadLocalFileToServer(String uploadFileName){ String AutomationPath = System.getProper ...

  7. FTP 搭建

    FTP 搭建 FTP 是 File Transfer Protocol(文件传输协议)的英文简称,它工作在 0SI 模型的第七层,TCP 模型的第四屋上,即应用层. 一.FTP 简介 FTP 会话时包 ...

  8. JVM知识

    堆(Heap)和非堆(Non-heap)内存 简单来说堆就是Java代码可及的内存,是留给开发人员使用的:非堆就是JVM留给 自己用的. 堆内存分配     JVM初始分配的内存由-Xms指定,默认是 ...

  9. org.json

    org.json很经典.能解析json和序列化List.Map为json,但是不能自动填充bean.不依赖其它架包. 直接上代码: import java.util.ArrayList; import ...

  10. jdk10运行springboot项目出现:Type javax.xml.bind.JAXBContext not present

    项目由openjdk8.0迁移到jdk10导致的 原因:java9模块化的概念使得JAXB默认没有加载: jaxb-api是存在jdk中的,只是默认没有加载而已,手动引入即可. 推荐方式: <! ...