CODE :
public class baseComboBoxItem : ComboBoxItem
{
public static DependencyProperty IsAllowHighlightProperty = DependencyProperty.Register("IsAllowHighlight", typeof(bool), typeof(baseComboBoxItem), new PropertyMetadata(
true));
//the "true" is for custom default value, because the type is "bool"
public baseComboBoxItem()
{
}
public bool IsAllowHighlight
{
get
{
return (bool)base.GetValue(IsAllowHighlightProperty);
}
set
{
base.SetValue(IsAllowHighlightProperty, value);
}
}
}
So, we can use IsAllowHighlight in XAML
<BC:baseComboBox x:Class="MakeMoney.BaseControls.comboColorPicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:BC="clr-namespace:MakeMoney.BaseControls"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Width="100" Height="26" SelectionChanged="baseComboBox_SelectionChanged">
<BC:baseComboBoxItem Background="#FF000000"
IsAllowHighlight="False"><TextBlock Text="" /></BC:baseComboBoxItem>
<BC:baseComboBoxItem Background="#FFCCCCCC"><TextBlock Text="" /></BC:baseComboBoxItem>
<BC:baseComboBoxItem Background="#FFDDDDDD"><TextBlock Text="" /></BC:baseComboBoxItem>
</BC:baseComboBox>
And also, for template triggers
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsHighlighted" Value="True"/>
<Condition Property="IsAllowHighlight" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="Bd" Value="{StaticResource baseHighlightedBackground}"/>
</MultiTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>