C# WPF ListViewItem颜色不正确
我已经设置了一个非常基本的测试来解决我在使用Visual Studio 2012并在Windows 8.1上运行的针对.NET Framework 4的WPF中遇到的颜色问题 问题是IsSelected和IsMouseOver触发器属性为屏幕生成不正确的颜色,而Snoop显示正确的值。屏幕上显示的实际颜色更“褪色”。也就是说,它们看起来比应该的轻。一个显示为#E5F3FB,另一个显示为#CBE8F6,但我在XAML中没有使用这两种颜色 截图:我不得不在这里做一些胡闹的事情,因为Snoop会更改选定项目的背景颜色。您在这里看到的是用户在不运行snoop的情况下会看到的内容。您可以看到,Snoop表示深蓝色,这是它应该的样子 现在是我的代码(只保留生成屏幕上四个项目所需的一点点代码,如果有帮助的话,我很乐意发布)C# WPF ListViewItem颜色不正确,c#,wpf,xaml,C#,Wpf,Xaml,我已经设置了一个非常基本的测试来解决我在使用Visual Studio 2012并在Windows 8.1上运行的针对.NET Framework 4的WPF中遇到的颜色问题 问题是IsSelected和IsMouseOver触发器属性为屏幕生成不正确的颜色,而Snoop显示正确的值。屏幕上显示的实际颜色更“褪色”。也就是说,它们看起来比应该的轻。一个显示为#E5F3FB,另一个显示为#CBE8F6,但我在XAML中没有使用这两种颜色 截图:我不得不在这里做一些胡闹的事情,因为Snoop会更改选
为什么选择ListView?我想在这里使用列表框。请尝试检查您的Windows颜色管理器设置,那里的设置有时会产生错误的颜色深浅。如果在RGB中包含Alpha,是否仍有这种情况?像#FF0072C6而不是#0072C6?@hedgehog,你的观点是什么?我想使用ListView。使用列表框不是一个选项。@ChrisW。是的,全十六进制也有同样的问题。
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ColorTest"
x:Class="MainWindow" Name="MainWindow" WindowStartupLocation="CenterScreen" >
<Grid>
<ListView Name="GroupsListView"
BorderThickness="0" >
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="#777777" />
<Setter Property="Foreground" Value="White" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="#0072C6" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="#2A8DD4" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
ItemWidth="{Binding (ListView.View).ItemWidth, RelativeSource={RelativeSource AncestorType=ListView}}"
MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}"
ItemHeight="{Binding (ListView.View).ItemHeight, RelativeSource={RelativeSource AncestorType=ListView}}" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid Width="140" Height="25">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Content="{Binding Name}" ToolTip="{Binding Name}" VerticalAlignment="center" HorizontalAlignment="Center"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Window>