如何将颜色设置为窗口的高亮颜色?

Kin*_*han 4 silverlight wpf colors selecteditem highlight

作为标题,如何?

我想在获得焦点时制作一个 TextBlock,它的背景颜色将是窗口操作系统的突出显示颜色(即您在 Internet Explorer 中突出显示文本时的颜色)。

有什么方法可以获得那个颜色代码,以便我可以将其放入样式中吗?

<Trigger Property="IsFocused" Value="True">
    <Setter Property="FontWeight" Value="Bold" />
    <Setter Property="Background" Value="Blue"/>
    <Setter Property="Foreground" Value="White"/>
</Trigger>
Run Code Online (Sandbox Code Playgroud)

Mar*_*all 6

我对你到底在要求什么有点困惑。选定的背景颜色或选定的文本颜色,以及您想要 WPF 还是 Silverlight。这将为您提供 WPF 中的突出显示背景画笔。

查看SystemColors 类,特别是SystemColors.HighlightBrush属性

<Setter Property="Background" Value="{x:Static SystemColors.HighlightBrush}" />
Run Code Online (Sandbox Code Playgroud)

至于 Silverlight 看看这个SO question