在 XAML 中动态使用 SystemColors

Using SystemColors dynamically in XAML

我希望我的应用程序能够处理 Windows 中的高对比度主题。要重现此问题,请先切换到高对比度主题。然后用 xaml:

中的这段代码创建一个简单的 WPF 应用程序
    <StackPanel>
        <CheckBox>A checkbox</CheckBox>
        <CheckBox Foreground="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}">ControlTextBrushKey</CheckBox>
    </StackPanel>

它在 UI

中看起来像这样

出于某种原因,无论我使用什么主题,ControlTextBrushKey 总是解析为#FFFFFFFF。我错过了什么?不应该也是绿色的吗?

以下是我的观察:

Windows 7: 如果选择了 High Contrast #2Aero Theme,那么 ControlTextBrushKey 如预期的那样是绿色的。但是如果选择High Contrast #1Aero Theme,ControlTextBrushKey returns白色。下面是 High Contrast #2Aero Theme

的屏幕截图

Windows 8: 无论默认主题的高对比度(High Contrast #1High Contrast #2),ControlTextBrushKey总是returns#FFFFFFFF

下面是 High Contrast #1High Contrast #2 的 table 取自 Here 并且它根据这个 [=58= 在 Windows 7 上工作].搜索 ControlTextBrush

高对比度 #1

高对比度 #2: