WPF Highlight brush for Combobox template The Next CEO of Stack OverflowWhat is the correct way to create a single-instance WPF application?Databinding an enum property to a ComboBox in WPFBinding a WPF ComboBox to a custom listVim clear last search highlightingHow to bind inverse boolean properties in WPF?Difference between Control Template and DataTemplate in WPFDoes my code demonstrate good WPF practice?combo box inside a user control disappears when style is applied in wpfComboBox in DataTemplate, items not highlighted on MouseOverWPF ComboBox get highlighted item

Writing differences on a blackboard

Is there always a complete, orthogonal set of unitary matrices?

Why isn't acceleration always zero whenever velocity is zero, such as the moment a ball bounces off a wall?

Why does standard notation not preserve intervals (visually)

Where do students learn to solve polynomial equations these days?

WOW air has ceased operation, can I get my tickets refunded?

Prepend last line of stdin to entire stdin

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

Why this way of making earth uninhabitable in Interstellar?

Rotate a column

Proper way to express "He disappeared them"

Why doesn't UK go for the same deal Japan has with EU to resolve Brexit?

What happened in Rome, when the western empire "fell"?

Does soap repel water?

Is it okay to majorly distort historical facts while writing a fiction story?

What steps are necessary to read a Modern SSD in Medieval Europe?

Why do airplanes bank sharply to the right after air-to-air refueling?

Grabbing quick drinks

When you upcast Blindness/Deafness, do all targets suffer the same effect?

INSERT to a table from a database to other (same SQL Server) using Dynamic SQL

Should I tutor a student who I know has cheated on their homework?

What connection does MS Office have to Netscape Navigator?

Is a distribution that is normal, but highly skewed considered Gaussian?

Is there a way to save my career from absolute disaster?



WPF Highlight brush for Combobox template



The Next CEO of Stack OverflowWhat is the correct way to create a single-instance WPF application?Databinding an enum property to a ComboBox in WPFBinding a WPF ComboBox to a custom listVim clear last search highlightingHow to bind inverse boolean properties in WPF?Difference between Control Template and DataTemplate in WPFDoes my code demonstrate good WPF practice?combo box inside a user control disappears when style is applied in wpfComboBox in DataTemplate, items not highlighted on MouseOverWPF ComboBox get highlighted item










0















I can't figure out how to set the Highlight brush of a Combobox (the color that will mark the item being selected on mouse over) to a certain Brush. I have used Edit Template -> Copy to get copy of the template where I try to set the SystemColors.HighlightBrushKey. I have seen answers that one should be able to set the brush by defining it like this in the Style resource, but it just does not work.



I have also tried to set the Grid's Style.Resource in which the comobox is placed, that did not help either.



Please see line 3 and line 15 where I set the color to red. No effect. What am I doing wrong?



 <Style x:Key="TeachpendantVMVisionServerComboBoxStyle" TargetType="x:Type ComboBox">
<Style.Resources>
<SolidColorBrush x:Key="x:Static SystemColors.HighlightBrushKey" Color="Red" />
<SolidColorBrush x:Key="x:Static SystemColors.ControlBrushKey" Color="Red" />
</Style.Resources>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="x:Type ComboBox">
<Grid x:Name="grid">
<Grid.Style>
<Style>
<Style.Resources>
<SolidColorBrush x:Key="x:Static SystemColors.HighlightBrushKey" Color="Red" />
<SolidColorBrush x:Key="x:Static SystemColors.ControlBrushKey" Color="Red" />
</Style.Resources>
</Style>
</Grid.Style>

<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition MaxWidth="18"/>
</Grid.ColumnDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ValidationStates">
<VisualState x:Name="Valid"/>
<VisualState x:Name="InvalidFocused">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush)" Storyboard.TargetName="PART_EditableTextBox">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<SolidColorBrush Color="Red"/>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill)" Storyboard.TargetName="path">
<DiscreteObjectKeyFrame KeyTime="0" Value="StaticResource MoveTextBox.Invalid.BorderBrush"/>
</ObjectAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="toggleButton">
<EasingColorKeyFrame KeyTime="0" Value="#FFFB0000"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="InvalidUnfocused">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush)" Storyboard.TargetName="PART_EditableTextBox">
<DiscreteObjectKeyFrame KeyTime="0" Value="StaticResource MoveTextBox.Invalid.BorderBrush"/>
</ObjectAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="toggleButton">
<EasingColorKeyFrame KeyTime="0" Value="Red"/>
</ColorAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill)" Storyboard.TargetName="path">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<SolidColorBrush Color="Red"/>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<TextBox x:Name="PART_EditableTextBox"
Padding="5,0,0,0"
Height="TemplateBinding Height">
<TextBox.Template>
<ControlTemplate TargetType="x:Type TextBox">
<Grid>
<Border
x:Name="border"
CornerRadius="3,0,0,3"
BorderThickness="1,1,0,1"
Background="DynamicResource Button.Static.Background"
BorderBrush="DynamicResource Button.Static.Background">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
</Grid>
</ControlTemplate>
</TextBox.Template>
</TextBox>
<ToggleButton x:Name="toggleButton" Grid.Column="1" Margin="0"
Height="TemplateBinding Height"
Focusable="False"
IsChecked="Binding IsDropDownOpen, Mode=TwoWay, RelativeSource=RelativeSource TemplatedParent"
ClickMode="Press" BorderBrush="#FFABADB3">
<ToggleButton.Template>
<ControlTemplate TargetType="x:Type ToggleButton">
<Border
Background="DynamicResource Button.Checked.Background"
x:Name="border"
CornerRadius="0,3,3,0"
BorderThickness="0,1,1,1"
BorderBrush="DynamicResource Button.Static.Background">
<ContentPresenter />
</Border>
</ControlTemplate>
</ToggleButton.Template>
<Path x:Name="path" Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 0 0 L 4 4 L 8 0 Z"
Fill="Gold" />
</ToggleButton>
<ContentPresenter x:Name="ContentSite"
Content="TemplateBinding SelectionBoxItem"
ContentTemplate="TemplateBinding SelectionBoxItemTemplate"
ContentTemplateSelector="TemplateBinding ItemTemplateSelector"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="5,0,0,0" RecognizesAccessKey="True"/>
<Popup x:Name="Popup"
Placement="Bottom"
IsOpen="TemplateBinding IsDropDownOpen"
AllowsTransparency="True"
Focusable="True"
PopupAnimation="Slide"
OverridesDefaultStyle="True">
<Grid x:Name="DropDown"
SnapsToDevicePixels="True"
MinWidth="TemplateBinding ActualWidth"
MaxHeight="TemplateBinding MaxDropDownHeight">
<Border
x:Name="DropDownBorder"
BorderThickness="1"
CornerRadius="5"
Background="Azure"
BorderBrush="DarkGray">
</Border>
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate/>
</Setter.Value>
</Setter>
</Style>









share|improve this question


























    0















    I can't figure out how to set the Highlight brush of a Combobox (the color that will mark the item being selected on mouse over) to a certain Brush. I have used Edit Template -> Copy to get copy of the template where I try to set the SystemColors.HighlightBrushKey. I have seen answers that one should be able to set the brush by defining it like this in the Style resource, but it just does not work.



    I have also tried to set the Grid's Style.Resource in which the comobox is placed, that did not help either.



    Please see line 3 and line 15 where I set the color to red. No effect. What am I doing wrong?



     <Style x:Key="TeachpendantVMVisionServerComboBoxStyle" TargetType="x:Type ComboBox">
    <Style.Resources>
    <SolidColorBrush x:Key="x:Static SystemColors.HighlightBrushKey" Color="Red" />
    <SolidColorBrush x:Key="x:Static SystemColors.ControlBrushKey" Color="Red" />
    </Style.Resources>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="x:Type ComboBox">
    <Grid x:Name="grid">
    <Grid.Style>
    <Style>
    <Style.Resources>
    <SolidColorBrush x:Key="x:Static SystemColors.HighlightBrushKey" Color="Red" />
    <SolidColorBrush x:Key="x:Static SystemColors.ControlBrushKey" Color="Red" />
    </Style.Resources>
    </Style>
    </Grid.Style>

    <Grid.ColumnDefinitions>
    <ColumnDefinition/>
    <ColumnDefinition MaxWidth="18"/>
    </Grid.ColumnDefinitions>
    <VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="ValidationStates">
    <VisualState x:Name="Valid"/>
    <VisualState x:Name="InvalidFocused">
    <Storyboard>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush)" Storyboard.TargetName="PART_EditableTextBox">
    <DiscreteObjectKeyFrame KeyTime="0">
    <DiscreteObjectKeyFrame.Value>
    <SolidColorBrush Color="Red"/>
    </DiscreteObjectKeyFrame.Value>
    </DiscreteObjectKeyFrame>
    </ObjectAnimationUsingKeyFrames>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill)" Storyboard.TargetName="path">
    <DiscreteObjectKeyFrame KeyTime="0" Value="StaticResource MoveTextBox.Invalid.BorderBrush"/>
    </ObjectAnimationUsingKeyFrames>
    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="toggleButton">
    <EasingColorKeyFrame KeyTime="0" Value="#FFFB0000"/>
    </ColorAnimationUsingKeyFrames>
    </Storyboard>
    </VisualState>
    <VisualState x:Name="InvalidUnfocused">
    <Storyboard>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush)" Storyboard.TargetName="PART_EditableTextBox">
    <DiscreteObjectKeyFrame KeyTime="0" Value="StaticResource MoveTextBox.Invalid.BorderBrush"/>
    </ObjectAnimationUsingKeyFrames>
    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="toggleButton">
    <EasingColorKeyFrame KeyTime="0" Value="Red"/>
    </ColorAnimationUsingKeyFrames>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill)" Storyboard.TargetName="path">
    <DiscreteObjectKeyFrame KeyTime="0">
    <DiscreteObjectKeyFrame.Value>
    <SolidColorBrush Color="Red"/>
    </DiscreteObjectKeyFrame.Value>
    </DiscreteObjectKeyFrame>
    </ObjectAnimationUsingKeyFrames>
    </Storyboard>
    </VisualState>
    </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <TextBox x:Name="PART_EditableTextBox"
    Padding="5,0,0,0"
    Height="TemplateBinding Height">
    <TextBox.Template>
    <ControlTemplate TargetType="x:Type TextBox">
    <Grid>
    <Border
    x:Name="border"
    CornerRadius="3,0,0,3"
    BorderThickness="1,1,0,1"
    Background="DynamicResource Button.Static.Background"
    BorderBrush="DynamicResource Button.Static.Background">
    <ScrollViewer x:Name="PART_ContentHost"/>
    </Border>
    </Grid>
    </ControlTemplate>
    </TextBox.Template>
    </TextBox>
    <ToggleButton x:Name="toggleButton" Grid.Column="1" Margin="0"
    Height="TemplateBinding Height"
    Focusable="False"
    IsChecked="Binding IsDropDownOpen, Mode=TwoWay, RelativeSource=RelativeSource TemplatedParent"
    ClickMode="Press" BorderBrush="#FFABADB3">
    <ToggleButton.Template>
    <ControlTemplate TargetType="x:Type ToggleButton">
    <Border
    Background="DynamicResource Button.Checked.Background"
    x:Name="border"
    CornerRadius="0,3,3,0"
    BorderThickness="0,1,1,1"
    BorderBrush="DynamicResource Button.Static.Background">
    <ContentPresenter />
    </Border>
    </ControlTemplate>
    </ToggleButton.Template>
    <Path x:Name="path" Grid.Column="1"
    HorizontalAlignment="Center"
    VerticalAlignment="Center"
    Data="M 0 0 L 4 4 L 8 0 Z"
    Fill="Gold" />
    </ToggleButton>
    <ContentPresenter x:Name="ContentSite"
    Content="TemplateBinding SelectionBoxItem"
    ContentTemplate="TemplateBinding SelectionBoxItemTemplate"
    ContentTemplateSelector="TemplateBinding ItemTemplateSelector"
    VerticalAlignment="Center"
    HorizontalAlignment="Right"
    Margin="5,0,0,0" RecognizesAccessKey="True"/>
    <Popup x:Name="Popup"
    Placement="Bottom"
    IsOpen="TemplateBinding IsDropDownOpen"
    AllowsTransparency="True"
    Focusable="True"
    PopupAnimation="Slide"
    OverridesDefaultStyle="True">
    <Grid x:Name="DropDown"
    SnapsToDevicePixels="True"
    MinWidth="TemplateBinding ActualWidth"
    MaxHeight="TemplateBinding MaxDropDownHeight">
    <Border
    x:Name="DropDownBorder"
    BorderThickness="1"
    CornerRadius="5"
    Background="Azure"
    BorderBrush="DarkGray">
    </Border>
    <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
    <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
    </ScrollViewer>
    </Grid>
    </Popup>
    </Grid>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    <Setter Property="Validation.ErrorTemplate">
    <Setter.Value>
    <ControlTemplate/>
    </Setter.Value>
    </Setter>
    </Style>









    share|improve this question
























      0












      0








      0








      I can't figure out how to set the Highlight brush of a Combobox (the color that will mark the item being selected on mouse over) to a certain Brush. I have used Edit Template -> Copy to get copy of the template where I try to set the SystemColors.HighlightBrushKey. I have seen answers that one should be able to set the brush by defining it like this in the Style resource, but it just does not work.



      I have also tried to set the Grid's Style.Resource in which the comobox is placed, that did not help either.



      Please see line 3 and line 15 where I set the color to red. No effect. What am I doing wrong?



       <Style x:Key="TeachpendantVMVisionServerComboBoxStyle" TargetType="x:Type ComboBox">
      <Style.Resources>
      <SolidColorBrush x:Key="x:Static SystemColors.HighlightBrushKey" Color="Red" />
      <SolidColorBrush x:Key="x:Static SystemColors.ControlBrushKey" Color="Red" />
      </Style.Resources>
      <Setter Property="HorizontalContentAlignment" Value="Center"/>
      <Setter Property="VerticalContentAlignment" Value="Center"/>
      <Setter Property="Template">
      <Setter.Value>
      <ControlTemplate TargetType="x:Type ComboBox">
      <Grid x:Name="grid">
      <Grid.Style>
      <Style>
      <Style.Resources>
      <SolidColorBrush x:Key="x:Static SystemColors.HighlightBrushKey" Color="Red" />
      <SolidColorBrush x:Key="x:Static SystemColors.ControlBrushKey" Color="Red" />
      </Style.Resources>
      </Style>
      </Grid.Style>

      <Grid.ColumnDefinitions>
      <ColumnDefinition/>
      <ColumnDefinition MaxWidth="18"/>
      </Grid.ColumnDefinitions>
      <VisualStateManager.VisualStateGroups>
      <VisualStateGroup x:Name="ValidationStates">
      <VisualState x:Name="Valid"/>
      <VisualState x:Name="InvalidFocused">
      <Storyboard>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush)" Storyboard.TargetName="PART_EditableTextBox">
      <DiscreteObjectKeyFrame KeyTime="0">
      <DiscreteObjectKeyFrame.Value>
      <SolidColorBrush Color="Red"/>
      </DiscreteObjectKeyFrame.Value>
      </DiscreteObjectKeyFrame>
      </ObjectAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill)" Storyboard.TargetName="path">
      <DiscreteObjectKeyFrame KeyTime="0" Value="StaticResource MoveTextBox.Invalid.BorderBrush"/>
      </ObjectAnimationUsingKeyFrames>
      <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="toggleButton">
      <EasingColorKeyFrame KeyTime="0" Value="#FFFB0000"/>
      </ColorAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      <VisualState x:Name="InvalidUnfocused">
      <Storyboard>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush)" Storyboard.TargetName="PART_EditableTextBox">
      <DiscreteObjectKeyFrame KeyTime="0" Value="StaticResource MoveTextBox.Invalid.BorderBrush"/>
      </ObjectAnimationUsingKeyFrames>
      <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="toggleButton">
      <EasingColorKeyFrame KeyTime="0" Value="Red"/>
      </ColorAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill)" Storyboard.TargetName="path">
      <DiscreteObjectKeyFrame KeyTime="0">
      <DiscreteObjectKeyFrame.Value>
      <SolidColorBrush Color="Red"/>
      </DiscreteObjectKeyFrame.Value>
      </DiscreteObjectKeyFrame>
      </ObjectAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      </VisualStateGroup>
      </VisualStateManager.VisualStateGroups>
      <TextBox x:Name="PART_EditableTextBox"
      Padding="5,0,0,0"
      Height="TemplateBinding Height">
      <TextBox.Template>
      <ControlTemplate TargetType="x:Type TextBox">
      <Grid>
      <Border
      x:Name="border"
      CornerRadius="3,0,0,3"
      BorderThickness="1,1,0,1"
      Background="DynamicResource Button.Static.Background"
      BorderBrush="DynamicResource Button.Static.Background">
      <ScrollViewer x:Name="PART_ContentHost"/>
      </Border>
      </Grid>
      </ControlTemplate>
      </TextBox.Template>
      </TextBox>
      <ToggleButton x:Name="toggleButton" Grid.Column="1" Margin="0"
      Height="TemplateBinding Height"
      Focusable="False"
      IsChecked="Binding IsDropDownOpen, Mode=TwoWay, RelativeSource=RelativeSource TemplatedParent"
      ClickMode="Press" BorderBrush="#FFABADB3">
      <ToggleButton.Template>
      <ControlTemplate TargetType="x:Type ToggleButton">
      <Border
      Background="DynamicResource Button.Checked.Background"
      x:Name="border"
      CornerRadius="0,3,3,0"
      BorderThickness="0,1,1,1"
      BorderBrush="DynamicResource Button.Static.Background">
      <ContentPresenter />
      </Border>
      </ControlTemplate>
      </ToggleButton.Template>
      <Path x:Name="path" Grid.Column="1"
      HorizontalAlignment="Center"
      VerticalAlignment="Center"
      Data="M 0 0 L 4 4 L 8 0 Z"
      Fill="Gold" />
      </ToggleButton>
      <ContentPresenter x:Name="ContentSite"
      Content="TemplateBinding SelectionBoxItem"
      ContentTemplate="TemplateBinding SelectionBoxItemTemplate"
      ContentTemplateSelector="TemplateBinding ItemTemplateSelector"
      VerticalAlignment="Center"
      HorizontalAlignment="Right"
      Margin="5,0,0,0" RecognizesAccessKey="True"/>
      <Popup x:Name="Popup"
      Placement="Bottom"
      IsOpen="TemplateBinding IsDropDownOpen"
      AllowsTransparency="True"
      Focusable="True"
      PopupAnimation="Slide"
      OverridesDefaultStyle="True">
      <Grid x:Name="DropDown"
      SnapsToDevicePixels="True"
      MinWidth="TemplateBinding ActualWidth"
      MaxHeight="TemplateBinding MaxDropDownHeight">
      <Border
      x:Name="DropDownBorder"
      BorderThickness="1"
      CornerRadius="5"
      Background="Azure"
      BorderBrush="DarkGray">
      </Border>
      <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
      <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
      </ScrollViewer>
      </Grid>
      </Popup>
      </Grid>
      </ControlTemplate>
      </Setter.Value>
      </Setter>
      <Setter Property="Validation.ErrorTemplate">
      <Setter.Value>
      <ControlTemplate/>
      </Setter.Value>
      </Setter>
      </Style>









      share|improve this question














      I can't figure out how to set the Highlight brush of a Combobox (the color that will mark the item being selected on mouse over) to a certain Brush. I have used Edit Template -> Copy to get copy of the template where I try to set the SystemColors.HighlightBrushKey. I have seen answers that one should be able to set the brush by defining it like this in the Style resource, but it just does not work.



      I have also tried to set the Grid's Style.Resource in which the comobox is placed, that did not help either.



      Please see line 3 and line 15 where I set the color to red. No effect. What am I doing wrong?



       <Style x:Key="TeachpendantVMVisionServerComboBoxStyle" TargetType="x:Type ComboBox">
      <Style.Resources>
      <SolidColorBrush x:Key="x:Static SystemColors.HighlightBrushKey" Color="Red" />
      <SolidColorBrush x:Key="x:Static SystemColors.ControlBrushKey" Color="Red" />
      </Style.Resources>
      <Setter Property="HorizontalContentAlignment" Value="Center"/>
      <Setter Property="VerticalContentAlignment" Value="Center"/>
      <Setter Property="Template">
      <Setter.Value>
      <ControlTemplate TargetType="x:Type ComboBox">
      <Grid x:Name="grid">
      <Grid.Style>
      <Style>
      <Style.Resources>
      <SolidColorBrush x:Key="x:Static SystemColors.HighlightBrushKey" Color="Red" />
      <SolidColorBrush x:Key="x:Static SystemColors.ControlBrushKey" Color="Red" />
      </Style.Resources>
      </Style>
      </Grid.Style>

      <Grid.ColumnDefinitions>
      <ColumnDefinition/>
      <ColumnDefinition MaxWidth="18"/>
      </Grid.ColumnDefinitions>
      <VisualStateManager.VisualStateGroups>
      <VisualStateGroup x:Name="ValidationStates">
      <VisualState x:Name="Valid"/>
      <VisualState x:Name="InvalidFocused">
      <Storyboard>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush)" Storyboard.TargetName="PART_EditableTextBox">
      <DiscreteObjectKeyFrame KeyTime="0">
      <DiscreteObjectKeyFrame.Value>
      <SolidColorBrush Color="Red"/>
      </DiscreteObjectKeyFrame.Value>
      </DiscreteObjectKeyFrame>
      </ObjectAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill)" Storyboard.TargetName="path">
      <DiscreteObjectKeyFrame KeyTime="0" Value="StaticResource MoveTextBox.Invalid.BorderBrush"/>
      </ObjectAnimationUsingKeyFrames>
      <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="toggleButton">
      <EasingColorKeyFrame KeyTime="0" Value="#FFFB0000"/>
      </ColorAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      <VisualState x:Name="InvalidUnfocused">
      <Storyboard>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush)" Storyboard.TargetName="PART_EditableTextBox">
      <DiscreteObjectKeyFrame KeyTime="0" Value="StaticResource MoveTextBox.Invalid.BorderBrush"/>
      </ObjectAnimationUsingKeyFrames>
      <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="toggleButton">
      <EasingColorKeyFrame KeyTime="0" Value="Red"/>
      </ColorAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill)" Storyboard.TargetName="path">
      <DiscreteObjectKeyFrame KeyTime="0">
      <DiscreteObjectKeyFrame.Value>
      <SolidColorBrush Color="Red"/>
      </DiscreteObjectKeyFrame.Value>
      </DiscreteObjectKeyFrame>
      </ObjectAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      </VisualStateGroup>
      </VisualStateManager.VisualStateGroups>
      <TextBox x:Name="PART_EditableTextBox"
      Padding="5,0,0,0"
      Height="TemplateBinding Height">
      <TextBox.Template>
      <ControlTemplate TargetType="x:Type TextBox">
      <Grid>
      <Border
      x:Name="border"
      CornerRadius="3,0,0,3"
      BorderThickness="1,1,0,1"
      Background="DynamicResource Button.Static.Background"
      BorderBrush="DynamicResource Button.Static.Background">
      <ScrollViewer x:Name="PART_ContentHost"/>
      </Border>
      </Grid>
      </ControlTemplate>
      </TextBox.Template>
      </TextBox>
      <ToggleButton x:Name="toggleButton" Grid.Column="1" Margin="0"
      Height="TemplateBinding Height"
      Focusable="False"
      IsChecked="Binding IsDropDownOpen, Mode=TwoWay, RelativeSource=RelativeSource TemplatedParent"
      ClickMode="Press" BorderBrush="#FFABADB3">
      <ToggleButton.Template>
      <ControlTemplate TargetType="x:Type ToggleButton">
      <Border
      Background="DynamicResource Button.Checked.Background"
      x:Name="border"
      CornerRadius="0,3,3,0"
      BorderThickness="0,1,1,1"
      BorderBrush="DynamicResource Button.Static.Background">
      <ContentPresenter />
      </Border>
      </ControlTemplate>
      </ToggleButton.Template>
      <Path x:Name="path" Grid.Column="1"
      HorizontalAlignment="Center"
      VerticalAlignment="Center"
      Data="M 0 0 L 4 4 L 8 0 Z"
      Fill="Gold" />
      </ToggleButton>
      <ContentPresenter x:Name="ContentSite"
      Content="TemplateBinding SelectionBoxItem"
      ContentTemplate="TemplateBinding SelectionBoxItemTemplate"
      ContentTemplateSelector="TemplateBinding ItemTemplateSelector"
      VerticalAlignment="Center"
      HorizontalAlignment="Right"
      Margin="5,0,0,0" RecognizesAccessKey="True"/>
      <Popup x:Name="Popup"
      Placement="Bottom"
      IsOpen="TemplateBinding IsDropDownOpen"
      AllowsTransparency="True"
      Focusable="True"
      PopupAnimation="Slide"
      OverridesDefaultStyle="True">
      <Grid x:Name="DropDown"
      SnapsToDevicePixels="True"
      MinWidth="TemplateBinding ActualWidth"
      MaxHeight="TemplateBinding MaxDropDownHeight">
      <Border
      x:Name="DropDownBorder"
      BorderThickness="1"
      CornerRadius="5"
      Background="Azure"
      BorderBrush="DarkGray">
      </Border>
      <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
      <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
      </ScrollViewer>
      </Grid>
      </Popup>
      </Grid>
      </ControlTemplate>
      </Setter.Value>
      </Setter>
      <Setter Property="Validation.ErrorTemplate">
      <Setter.Value>
      <ControlTemplate/>
      </Setter.Value>
      </Setter>
      </Style>






      wpf combobox styles datatemplate highlight






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 16:40









      JohanJohan

      12611




      12611






















          1 Answer
          1






          active

          oldest

          votes


















          0














          It was fairly simple after all (but not obvious where to find it).
          Just edit a copy of the ItemsContainerStyle and all these Brushes can be set from there.



          To Change the layout of the ComboBox (creating a round combobox or changing colors)
          Style="DynamicResource MyComboBoxStyle"



          To Change the hoover and selected Highlight colors



          ItemContainerStyle="DynamicResource MyComboBoxItemS"


          The complete Combobox would look like this then in XAML



          <ComboBox x:Name="positionsComboBox"
          Grid.Column="1"
          Grid.ColumnSpan="3"
          IsReadOnly = "True"
          IsEditable = "False"
          Margin="3,0,3,0"
          ItemsSource="Binding IDs, Source=StaticResource Locator, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay"
          SelectedValue="Binding SelectedID, Source=StaticResource Locator, Mode=TwoWay"
          Style="DynamicResource MyComboBoxStyle"
          IsSynchronizedWithCurrentItem="True"
          ItemContainerStyle="DynamicResource MyComboBoxItemContainerStyle"
          FontWeight="Bold"
          FontSize="24"/>





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55048829%2fwpf-highlight-brush-for-combobox-template%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            It was fairly simple after all (but not obvious where to find it).
            Just edit a copy of the ItemsContainerStyle and all these Brushes can be set from there.



            To Change the layout of the ComboBox (creating a round combobox or changing colors)
            Style="DynamicResource MyComboBoxStyle"



            To Change the hoover and selected Highlight colors



            ItemContainerStyle="DynamicResource MyComboBoxItemS"


            The complete Combobox would look like this then in XAML



            <ComboBox x:Name="positionsComboBox"
            Grid.Column="1"
            Grid.ColumnSpan="3"
            IsReadOnly = "True"
            IsEditable = "False"
            Margin="3,0,3,0"
            ItemsSource="Binding IDs, Source=StaticResource Locator, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay"
            SelectedValue="Binding SelectedID, Source=StaticResource Locator, Mode=TwoWay"
            Style="DynamicResource MyComboBoxStyle"
            IsSynchronizedWithCurrentItem="True"
            ItemContainerStyle="DynamicResource MyComboBoxItemContainerStyle"
            FontWeight="Bold"
            FontSize="24"/>





            share|improve this answer



























              0














              It was fairly simple after all (but not obvious where to find it).
              Just edit a copy of the ItemsContainerStyle and all these Brushes can be set from there.



              To Change the layout of the ComboBox (creating a round combobox or changing colors)
              Style="DynamicResource MyComboBoxStyle"



              To Change the hoover and selected Highlight colors



              ItemContainerStyle="DynamicResource MyComboBoxItemS"


              The complete Combobox would look like this then in XAML



              <ComboBox x:Name="positionsComboBox"
              Grid.Column="1"
              Grid.ColumnSpan="3"
              IsReadOnly = "True"
              IsEditable = "False"
              Margin="3,0,3,0"
              ItemsSource="Binding IDs, Source=StaticResource Locator, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay"
              SelectedValue="Binding SelectedID, Source=StaticResource Locator, Mode=TwoWay"
              Style="DynamicResource MyComboBoxStyle"
              IsSynchronizedWithCurrentItem="True"
              ItemContainerStyle="DynamicResource MyComboBoxItemContainerStyle"
              FontWeight="Bold"
              FontSize="24"/>





              share|improve this answer

























                0












                0








                0







                It was fairly simple after all (but not obvious where to find it).
                Just edit a copy of the ItemsContainerStyle and all these Brushes can be set from there.



                To Change the layout of the ComboBox (creating a round combobox or changing colors)
                Style="DynamicResource MyComboBoxStyle"



                To Change the hoover and selected Highlight colors



                ItemContainerStyle="DynamicResource MyComboBoxItemS"


                The complete Combobox would look like this then in XAML



                <ComboBox x:Name="positionsComboBox"
                Grid.Column="1"
                Grid.ColumnSpan="3"
                IsReadOnly = "True"
                IsEditable = "False"
                Margin="3,0,3,0"
                ItemsSource="Binding IDs, Source=StaticResource Locator, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay"
                SelectedValue="Binding SelectedID, Source=StaticResource Locator, Mode=TwoWay"
                Style="DynamicResource MyComboBoxStyle"
                IsSynchronizedWithCurrentItem="True"
                ItemContainerStyle="DynamicResource MyComboBoxItemContainerStyle"
                FontWeight="Bold"
                FontSize="24"/>





                share|improve this answer













                It was fairly simple after all (but not obvious where to find it).
                Just edit a copy of the ItemsContainerStyle and all these Brushes can be set from there.



                To Change the layout of the ComboBox (creating a round combobox or changing colors)
                Style="DynamicResource MyComboBoxStyle"



                To Change the hoover and selected Highlight colors



                ItemContainerStyle="DynamicResource MyComboBoxItemS"


                The complete Combobox would look like this then in XAML



                <ComboBox x:Name="positionsComboBox"
                Grid.Column="1"
                Grid.ColumnSpan="3"
                IsReadOnly = "True"
                IsEditable = "False"
                Margin="3,0,3,0"
                ItemsSource="Binding IDs, Source=StaticResource Locator, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay"
                SelectedValue="Binding SelectedID, Source=StaticResource Locator, Mode=TwoWay"
                Style="DynamicResource MyComboBoxStyle"
                IsSynchronizedWithCurrentItem="True"
                ItemContainerStyle="DynamicResource MyComboBoxItemContainerStyle"
                FontWeight="Bold"
                FontSize="24"/>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 7 at 19:09









                JohanJohan

                12611




                12611





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55048829%2fwpf-highlight-brush-for-combobox-template%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    1928 у кіно

                    Захаров Федір Захарович

                    Ель Греко