主要通过设置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 8 联系人ABPeoplePickerNavigationController

    一. ios 联系人ABPeoplePickerNavigationControllerDelegate方法,新添加下面两个联系人选中方法,适配iOS8需要实现 // Called after a p ...

  2. vue2.0 tab切换几种方式

    第一种 比较灵活简单的方式(切换改变部分的内容在组件中比较方便操作) <template> <div id="app"> <ul> <li ...

  3. Go开发之VScode安装

    1.找到官网 https://code.visualstudio.com/ 2根据自己机器环境下载 3.下载vscode地址,macos版本 https://vscode.cdn.azure.cn/s ...

  4. xtrabackup拷贝redolog前做的细节操作

    原文地址:http://www.innomysql.net/article/25590.html 前言 淘宝3月的数据库内核月报对 xtrabackup的备份原理 做了深入的分析,写的还是很不错.不过 ...

  5. POJ 1135.Domino Effect Dijkastra算法

    Domino Effect Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10325   Accepted: 2560 De ...

  6. ubuntu 设置静态ip地址不生效问题

    出现了一个问题是,配置了静态ip地址之后,重启网络服务,查看ip地址是生效的,过会再看就 不生效了,查看网上说是由于 network-manager 管理ip地址时候出现的冲突,将network-ma ...

  7. Laravel 中使用原生的 PHPExcel

    1.安装 composer require maatwebsite/excel 之后,程序中就可以使用 PHPExcel 了 2.控制器中 public function export(Request ...

  8. windows10 装linux子系统

    http://blog.csdn.net/Yuxin_Liu/article/details/52347898 试了一下,下载太慢,就没继续用,可以用实验楼这个网来玩玩linux

  9. 重新学习pytorch的库函数等..

    http://blog.csdn.net/victoriaw/article/list/10 开始第一篇: http://blog.csdn.net/VictoriaW/article/details ...

  10. kubernetes pod、service文件yaml模版格式

    apiVersion: v1 #必选,版本号,例如v1,版本号必须可以用 kubectl api-versions 查询到 . kind: Pod #必选,Pod metadata: #必选,元数据 ...