相关疑难解决方法(0)

WPF ListView非活动选择颜色

我正在创建一个WPF应用程序,其中连续生成多个ListView选项(类似于iTunes浏览器).问题是默认的非活动选择颜色太浅.(见下文) 默认非活动选择颜色(太亮)

如何更改此颜色,以便我的非活动列表视图如下所示?(见下文) 非活动和主动选择颜色相同

使用Style类似的方法覆盖默认的SystemColor :

<Style TargetType="ListViewItem">
    <Style.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{x:Static SystemColors.HighlightColor}"/>
    </Style.Resources>
</Style>
Run Code Online (Sandbox Code Playgroud)

wpf listview selection

65
推荐指数
4
解决办法
4万
查看次数

如何设置WPF ListView选择项目颜色?

我试图在Windows 7上运行的WPF应用程序中从Windows 8重新创建Mail UI.这是我想要实现的:

目标UI

特别是,我不知道如何更改所选项目的背景颜色,例如第一列中的收件箱项目和第二列中来自Twitter的邮件.我尝试过其他类似的Stackoverflow问题的几个解决方案,但似乎没有一个适合我.例如

当焦点在WPF ListBox中移出时,所选项目会丢失样式

WPF ListView非活动选择颜色

这是我的listview代码:

<ListView Grid.Row="0" SelectedItem="{Binding Path=SelectedArea}" ItemsSource="{Binding Path=Areas}" Background="#DCE3E5" >

                    <ListView.Resources>

                        <!-- Template that is used upon selection of an Area -->
                        <ControlTemplate x:Key="SelectedTemplate" TargetType="ListViewItem">
                            <Border Background="#388095" Cursor="Hand" >
                                <TextBlock Text="{Binding Name}" Margin="5" />
                            </Border>                                
                        </ControlTemplate>

                        <Style TargetType="ListViewItem">
                            <Setter Property="Template">
                                <Setter.Value>                                        
                                    <!-- Base Template that is replaced upon selection -->
                                    <ControlTemplate TargetType="ListViewItem">
                                        <Border Background="#DCE3E5" Cursor="Hand"  >
                                            <TextBlock Text="{Binding Name}" Margin="5" />
                                        </Border>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                            <Style.Triggers>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsSelected" Value="true" /> …
Run Code Online (Sandbox Code Playgroud)

wpf listview styles background-color listviewitem

13
推荐指数
2
解决办法
4万
查看次数