作为标题,如何?
我想在聚焦时制作一个 TextBlock,它的背景颜色将是窗口操作系统的突出显示颜色(即您在 Internet Explorer 中突出显示文本时的颜色)。
有什么方法可以获得那个颜色代码,以便我可以将其放入样式中吗?
<Trigger Property="IsFocused" Value="True">
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Background" Value="Blue"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
最佳答案
我对你到底在要求什么有点困惑。选定的背景颜色或选定的文本颜色,以及您想要 WPF 还是 Silverlight。这将为您提供 WPF 中的突出显示背景画笔。
看SystemColors Class特别是 SystemColors.HighlightBrush属性(property)
<Setter Property="Background" Value="{x:Static SystemColors.HighlightBrush}" />
至于 Silverlight 看看这个 SO question
关于wpf - 如何将颜色设置为窗口的高亮颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9549128/