更改Windows经典主题中的禁用列表框的背景颜色 [英] Change background color of disabled listbox in windows classic theme

查看:104
本文介绍了更改Windows经典主题中的禁用列表框的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发必须使用Windows Classic主题运行的WPF应用程序。该应用程序将创建一个包含ListBox的对话框。显示对话框时,必须先禁用1秒钟,然后再接受任何输入。我使用样式触发器来完成此操作,并且它可以正常工作。但是,列表框在禁用时会显示白色背景,我似乎无法消除它。使用Aero主题时,以下样式资源可解决此问题:

I am developing a WPF application that must run using Windows Classic theme. The application creates a dialog box containing a ListBox. When the dialog box is shown, it must be disabled for 1s before accepting any input. I am accomplishing this with a style trigger, and it works. However, the ListBox shows a white background when it's disabled, which I can't seem to get rid of. When using the aero theme, the following style resource fixes the issue:

<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>

但是使用Windows经典主题时,白色背景会重新出现。我该如何纠正经典主题的情况??

But when using Windows Classic theme, the white background reappears. How can i remedy the situation for Classic theme???

推荐答案

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

After further research, I discovered that the Windows Classic theme uses WindowBrushKey instead of ControlBrushKey. Therefore, this fixes the issue for both Aero and Classic themes:

<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>

这篇关于更改Windows经典主题中的禁用列表框的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆