c# - 选定的 ListViewItem 颜色在 Windows-XP 中发生变化,但在 Windows-7 中不变

标签 c# xaml windows-7

我有一个 ListView,我希望 selectedItem 的背景为红色。它在 Windows-XP 中工作得很好,但在 Windows-7 中没有任何变化。 Windows XP 的默认选择是蓝色背景,但在 Windows7 中我只在 ListViewItem 下看到一条细蓝线,没有其他背景颜色。有什么我不知道的应该为 Windows-7 添加的内容吗?非常感谢你的帮助。

这就是我的 xaml 的样子:

<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource DefaultControlStyle}">
    <Setter Property="Cursor" Value="Hand" />
    <Setter Property="Height" Value="25" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="Background" Value="{StaticResource RowBackgroundBrush}" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="ToolTip" Value="{Binding ItemToolTip}" />
    <Style.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF0000"/>
        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#FF0000"/>
    </Style.Resources>
</Style>

如果您需要更多信息,请告诉我。

/N

最佳答案

此 XAML 在 Windows 7 中运行良好,将所选项目显示为红色..

由于我们不知道您所基于的 DefaultControlStyle 是什么,我猜测这就是给您带来问题的地方。

我建议您创建一个不带 DefaultControlStyle 的全新副项目(仅使用上述 XAML)并亲自查看。

关于c# - 选定的 ListViewItem 颜色在 Windows-XP 中发生变化,但在 Windows-7 中不变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15496482/

相关文章:

wpf - 边距和填充和边界框的贡献有什么区别?

wpf - 覆盖切换按钮样式

php - 无法在 Windows 7 上使用 PHP 连接到 MySQL

c# - 我可以从非虚拟化应用程序访问 Windows 虚拟商店中的文件和注册表项吗?

c# - 两个包含接口(interface)的列表与一个包含具有两个接口(interface)的结构的列表

c# - 如何在 c#.net 中的形状文件上绘制多边形?

c# - 为什么找不到我的 ResourceDictionary xaml 文件?

c# - 为什么 Windows 7 跳转列表中只显示带有我的文件扩展名的文件?

c# - 使用Try-Catch-Finally处理算术异常

C# 图像识别性能——比较图像列表和图像字典