Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change background color of disabled listbox in windows classic theme

Tags:

wpf

themes

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

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

like image 224
Greg Ferreri Avatar asked Apr 07 '10 17:04

Greg Ferreri


1 Answers

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>
like image 64
Greg Ferreri Avatar answered Oct 29 '22 21:10

Greg Ferreri