本地覆盖系统颜色

时间:2015-02-16 11:22:08

标签: wpf

我试图通过重写SystemColors.HighlightBrushKey来更改列表框项的高亮笔刷颜色。但不幸的是,它不能使用以下代码。

<ListBox x:Name="lstItems"  >
    <ListBox.Resources>
        <Style TargetType="ListBoxItem">
            <Style.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Red" />
            </Style.Resources>
        </Style>
    </ListBox.Resources>
</ListBox>

我的代码来自此WPFTutorial.net page,您可以在其中看到所选项目以红色突出显示。

但我仍然会获得默认行为,如以下屏幕截图所示。 enter image description here

我正在使用.NET 4.5进行开发

我在这里缺少什么?

0 个答案:

没有答案