views:

190

answers:

1

I have the following style defined which is being applied (as text changes to red) but I cannot seem to get the Background property to work. Can anyone tell me what is wrong with this?

    <Style x:Key="CompanyComboItemContainerStyle" TargetType="ComboBoxItem">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="Red" />
                            <Setter Property="Background" Value="Black" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                    <StackPanel>
                        <TextBlock Text="{Binding CompanyName}" Grid.Column="0" />
                        <TextBlock Text="{Binding EIC, StringFormat=' ({0})'}" Grid.Column="1" FontFamily="Courier New" FontWeight="Bold" FontSize="12" />
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
+2  A: 

On your StackPanel have you tried adding Background="{TemplateBinding Background}"?

sixlettervariables
THANK YOU SO MUCH!!!! I tried to figure out what that template binding background thing was, but with no luck!! THANKS!!!
LnDCobra