我有一个 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/