先上图

解决方法:

<ListView ...>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Style.Resources>
<!-- Foreground for Selected ListViewItem -->
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}"
Color="Black"/>
<!-- Background for Selected ListViewItem -->
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Transparent"/>
</Style.Resources>
</Style>
</ListView.ItemContainerStyle>
...
</ListView>

解决问题

在CSDN上找到另外一种方法:

用StyleSnooper看一下默认的Style,改一下就可以了。

三种颜色 IsMouseOver = Blue
Select & Focus = Red
Select & UnFocus = Yellow

大家也可以尝试下:

<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<Style TargetType="ListViewItem">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Yellow"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color=" Red"/>
</Style.Resources>
<Setter Property="Panel.Background" Value="#00FFFFFF"/>
<Setter Property="Control.HorizontalContentAlignment">
<Setter.Value>
<Binding Path="HorizontalContentAlignment"
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
</Setter.Value>
</Setter>
<Setter Property="Control.VerticalContentAlignment">
<Setter.Value>
<Binding Path="VerticalContentAlignment"
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
</Setter.Value>
</Setter>
<Setter Property="Control.Padding" Value="2,0,0,0"/>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Border BorderThickness="{TemplateBinding Border.BorderThickness}"
Padding="{TemplateBinding Control.Padding}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
Name="Bd"
SnapsToDevicePixels="True">
<ContentPresenter
Content="{TemplateBinding ContentControl.Content}"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Selector.IsSelected" Value="True">
<Setter Property="Panel.Background" TargetName="Bd">
<Setter.Value>
<DynamicResource ResourceKey="{x:Static SystemColors.HighlightBrushKey}" />
</Setter.Value>
</Setter>
<Setter Property="TextElement.Foreground">
<Setter.Value>
<DynamicResource ResourceKey="{x:Static SystemColors.HighlightTextBrushKey}" />
</Setter.Value>
</Setter>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Selector.IsSelected" Value="True"/>
<Condition Property="Selector.IsSelectionActive" Value="False"/>
</MultiTrigger.Conditions>
<Setter Property="Panel.Background" TargetName="Bd">
<Setter.Value>
<DynamicResource ResourceKey="{x:Static SystemColors.ControlBrushKey}" />
</Setter.Value>
</Setter>
<Setter Property="TextElement.Foreground">
<Setter.Value>
<DynamicResource ResourceKey="{x:Static SystemColors.ControlTextBrushKey}" />
</Setter.Value>
</Setter>
</MultiTrigger>
<Trigger Property="UIElement.IsEnabled" Value="False">
<Setter Property="TextElement.Foreground">
<Setter.Value>
<DynamicResource ResourceKey="{x:Static SystemColors.GrayTextBrushKey}" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter Property="Panel.Background" TargetName="Bd" Value="Blue">
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<ListView Margin="48,22,110,0" Name="listView1" Height="100" VerticalAlignment="Top">
<ListView.View>
<GridView>
<GridViewColumn Header="12"/>
<GridViewColumn Header="12"/>
<GridViewColumn Header="12"/>
</GridView>
</ListView.View>
<ListViewItem>123</ListViewItem>
<ListViewItem>123</ListViewItem>
<ListViewItem>123</ListViewItem>
</ListView>
<TextBox Height="23" Margin="94,0,64,67" Name="textBox1" VerticalAlignment="Bottom" />
</Grid>
</Window>

var isLogined = false; var cb_blogId = 69072; var cb_entryId = 3335531; var cb_blogApp = currentBlogApp; var cb_blogUserGuid = "c846af3f-b66b-de11-9510-001cf0cd104b"; var cb_entryCreatedDate = '2013/9/23 18:50:00'; var enableGoogleAd = true; var googletag = googletag || {}; googletag.cmd = googletag.cmd || [];

WPF中ListView如何改变选中条背景颜色的更多相关文章

  1. WPF中ListBox /ListView如何改变选中条背景颜色

    适用ListBox /ListView WPF中LISTVIEW如何改变选中条背景颜色 https://www.cnblogs.com/sjqq/p/7828119.html

  2. 如何在Word表格中的某一栏添加背景颜色

     如何在Word表格中的某一栏添加背景颜色 编写人:CC阿爸 2014-3-14 用鼠标选中某一个单元格然后右键单击 下拉菜单选择.<边框和低纹>然后点<低纹>选项卡 选中色卡 ...

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

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

  4. Android中的ListView点击时的背景颜色设置

    想设置listview中每行在点击.选中等不同状态下有不同的背景颜色,或者背景图片. 这可以用Android的Selector来实现.它可以定义组件在不同状态下的显示方式. 新建一个xml文件list ...

  5. 改变Android按钮背景颜色的高效方法

    本文将介绍一种有效改变Android按钮颜色的方法. 按钮可以在状态改变时改变其颜色(例如按下,禁用,高亮显示).但是,这需要一一说明每个状态.这篇文章将提供你一个根据状态变化轻松改变按钮颜色的方法. ...

  6. Android使用属性动画ValueAnimator动态改变SurfaceView的背景颜色

    以下是主要代码,难点和疑问点都写在注释中: /** * 开始背景动画(此处为属性动画) */ private void startBackgroundAnimator(){ /* *参数解释: *ta ...

  7. actionMode-theme中修改actionmode中more下拉框的背景颜色

    今天在做图库修改是,需要修改图库的actionbar某个按钮弹出来的下拉框的背景颜色,在网上找了个方法尝试下,没有打到自己的要求,不过阴差阳错的却修改了more下拉框的背景,再次记录下,也许以后能用的 ...

  8. 改变 TMemo 的背景颜色 (Firemonkey)

    说明:展示使用程序码改变 Firemonkey TMemo 的背景颜色. 适用:XE6 源码下载:[原創]Memo改背景色_XE6.zip //---------------------------- ...

  9. MFC中给各个控件填充背景颜色的方法

    1.给程序设置大背景色,在OnPaint()函数中添加如下代码: CRect rect; CPaintDC dc(this); GetClientRect(rect); dc.FillSolidRec ...

随机推荐

  1. TokuDB介绍——本质是分形树(一个叶子4MB)+缓存减少写操作

    其性能特点见:http://www.cnblogs.com/billyxp/p/3567421.html TokuDB 是一个高性能.支持事务处理的 MySQL 和 MariaDB 的存储引擎.Tok ...

  2. BZOJ1937 [Shoi2004]Mst 最小生成树

    首先由贪心的想法知道,树边只减不加,非树边只加不减,令$w_i$表示i号边原来的边权,$d_i$表示i号边的改变量 对于一条非树边$j$连接着两个点$x$.$y$,则对于$xy$这条路径上的所有树边$ ...

  3. Google Chrome 源码下载地址 (Google Chrome Source Code Download)

    1. Google Chrome 源码 SVN 地址:http://src.chromium.org/svn.包含有 Chrome.Gears.Webkit.GCC 等源码以及编译依赖工具.Chrom ...

  4. PDF 补丁丁 0.4.1.804 测试版发布:合并文件夹的图片和PDF文件,自由生成多层次书签

    新的测试版增强了合并文件的功能,可以合并文件夹内的图片和PDF文件,还可以在合并文件列表上直接指定与合并文件对应的PDF书签标题.通过拖放文件项目生成多层次的PDF书签.如下图所示: 另外,新的测试版 ...

  5. php 应用 cpu 100% 调试方法

    找出进程占用cpu高的原因. 进程占用cpu高,一般是由于进程长时间占用cpu,又没有主动释放占用.如果想主动释放cpu,可以调用sleep.在写程序的时候,尤其要注意while 等循环的地方. 找出 ...

  6. JBoss JMX登录需要用户名密码的解决办法

    /opt/jboss/eap5.1.2/jboss-as/server/default/conf/props/jmx-console-users.properties 取消#admin=admin的注 ...

  7. drbd

    1.DRBD安装 1.1.安装依赖包: [java] view plaincopy yum -y install gcc kernel-devel kernel-headers flex 下载安装dr ...

  8. [Js]Ajax

    一.什么是Ajax 不刷新的情况下读取数据或提交数据 (最早出现ajax:谷歌地图,拖动一下出现一片新的视野) 应用:用户注册.在线聊天.微博 特性:只能从服务器上去读取数据(所以我们需要配置自己的服 ...

  9. iOS 文件读写

    #import <Foundation/Foundation.h> @interface Utils : NSObject +(void) writeFile:(NSString *) f ...

  10. ssl和https协议详解

    转自:https://cuiyongxiu.com/201102/24157.html ssl协议的起源和历史我就不再多说了,就是那个Netscape 网景公司开发的,它的作用主要是提供了一种安全传输 ...