C#C
C#11mo ago
wildREA

XAML property issues

My markup apparently does nothing for Backgorund, but it does for 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.

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>
image.png
Was this page helpful?