© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•12mo ago
wildREA

XAML property issues

My markup apparently does nothing for
Backgorund
Backgorund
, but it does for
Foreground
Foreground
. How does that make sense? I need help setting a selected background to the same as the non-selected ones as well as using the same hover color as my button, which apparently doesn't work for the ComboBox(Item), but it does for
Button
Button
.

XAML

<UserControl.Resources>
    <Style TargetType="{x:Type ComboBox}">
        <Setter Property="Background" Value="{DynamicResource PanelBackground}" />
        <Setter Property="Foreground" Value="{DynamicResource TextColor}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
    </Style>

    <Style TargetType="{x:Type ComboBoxItem}">
        <Setter Property="Background" Value="{DynamicResource PanelBackground}" />
        <Setter Property="Foreground" Value="{DynamicResource TextColor}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
        <Setter Property="Padding" Value="4,2" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{DynamicResource HoverColor}" />
            </Trigger>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="{DynamicResource PanelBackground}" />
                <Setter Property="Foreground" Value="{DynamicResource TextColor}" />
            </Trigger>
        </Style.Triggers>
    </Style>
<UserControl.Resources>
    <Style TargetType="{x:Type ComboBox}">
        <Setter Property="Background" Value="{DynamicResource PanelBackground}" />
        <Setter Property="Foreground" Value="{DynamicResource TextColor}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
    </Style>

    <Style TargetType="{x:Type ComboBoxItem}">
        <Setter Property="Background" Value="{DynamicResource PanelBackground}" />
        <Setter Property="Foreground" Value="{DynamicResource TextColor}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
        <Setter Property="Padding" Value="4,2" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{DynamicResource HoverColor}" />
            </Trigger>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="{DynamicResource PanelBackground}" />
                <Setter Property="Foreground" Value="{DynamicResource TextColor}" />
            </Trigger>
        </Style.Triggers>
    </Style>
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

Problem with corner radius XAML property
C#CC# / help
2y ago
❔ XAML accessing property of parent views element
C#CC# / help
3y ago
Static property issues
C#CC# / help
2y ago
✅ xaml
C#CC# / help
9mo ago