© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
2 replies
wakalaz

❔ how i can change the background color of this listbox?

i made this custom style but only work foreground, background don't work
<Style TargetType="ListBoxItem" x:Key="MainListBoxItem">
        <Setter Property="Background" Value="Transparent"/>
        <Style.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
                             Color="Transparent"/>
        </Style.Resources>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="Green"/>
                <Setter Property="Foreground" Value="Red"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Red" />
                <Setter Property="Foreground" Value="Blue"/>
            </Trigger>
        </Style.Triggers>
    </Style>
<Style TargetType="ListBoxItem" x:Key="MainListBoxItem">
        <Setter Property="Background" Value="Transparent"/>
        <Style.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
                             Color="Transparent"/>
        </Style.Resources>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="Green"/>
                <Setter Property="Foreground" Value="Red"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Red" />
                <Setter Property="Foreground" Value="Blue"/>
            </Trigger>
        </Style.Triggers>
    </Style>
image.png
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ c# wpf change background color of whitespace character
C#CC# / help
3y ago
Background color of .net
C#CC# / help
2y ago
✅ How can I change this code
C#CC# / help
2y ago
❔ how can WPF change the hover mouseover color of something like Winforms can?
C#CC# / help
4y ago