在Windows经典主题中更改禁用列表框的背景颜色

Gre*_*eri 6 wpf themes aero

我正在开发一个必须使用Windows经典主题运行的WPF应用程序.该应用程序创建一个包含ListBox的对话框.显示对话框时,在接受任何输入之前必须禁用1秒.我用一个样式触发器来完成它,它的工作原理.但是,ListBox在禁用时显示白色背景,我似乎无法摆脱它.使用aero主题时,以下样式资源可修复此问题:

<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
Run Code Online (Sandbox Code Playgroud)

但是在使用Windows经典主题时,会再次出现白色背景.我怎样才能解决经典主题的情况???

Gre*_*eri 9

经过进一步研究,我发现Windows Classic主题使用WindowBrushKey而不是ControlBrushKey.因此,这解决了Aero和Classic主题的问题:

<Style TargetType="{x:Type ListBox}">
    <Style.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
        <SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="Transparent"/>
    </Style.Resources>
Run Code Online (Sandbox Code Playgroud)