Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...