2

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

4

1 回答 1

2

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

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

我建议您在没有(仅使用上述 XAML)的情况下创建一个干净的新项目DefaultControlStyle并亲自查看。

于 2013-03-19T10:15:05.383 回答