How to swap up/down buttons in NumericUpDown control of MahApps.Metro? - wpf

I am currently using the MahApps.Metro NumericUpDown control to change frames in an image stack. The user feedback I have got from this is that the buttons feel the wrong way round, intuitively the button on the left would move back a frame and the button on the right would move forward. As such I would like to swap the order of the buttons
I have looked through the properties that the control has but I have been unable to find any that would allow me to change the order of the buttons.
Is there a way to do this without having to roll my own control?
Basically I would like to change from this:
To this:

Update
With latest MahApps version (v2.x) there is the new SwitchUpDownButtons property available to swap / switch the buttons.
Older MahApps Versions
There is no property where you can change the sequence of the up and down buttons. But you can take the original style which is available at the GitHub repository of MahApps.Metro and change the Template.
<Style x:Key="CustomNumericUpDownStyle" TargetType="{x:Type Controls:NumericUpDown}" BasedOn="{StaticResource {x:Type Controls:NumericUpDown}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:NumericUpDown}">
<Grid SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
<Border x:Name="Base"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding Controls:ControlsHelper.CornerRadius}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Grid Margin="{TemplateBinding BorderThickness}">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="PART_TextBoxColumn" Width="*" />
<ColumnDefinition x:Name="PART_ButtonsColumn" Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox x:Name="PART_TextBox"
Grid.Column="0"
MinWidth="20"
MinHeight="0"
Margin="0 0 -2 0"
Padding="0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Controls:ControlsHelper.DisabledVisualElementVisibility="Collapsed"
Controls:TextBoxHelper.ButtonContent="{TemplateBinding Controls:TextBoxHelper.ButtonContent}"
Controls:TextBoxHelper.ButtonContentTemplate="{TemplateBinding Controls:TextBoxHelper.ButtonContentTemplate}"
Controls:TextBoxHelper.ButtonFontFamily="{TemplateBinding Controls:TextBoxHelper.ButtonFontFamily}"
Controls:TextBoxHelper.ButtonFontSize="{TemplateBinding Controls:TextBoxHelper.ButtonFontSize}"
Controls:TextBoxHelper.ButtonWidth="{TemplateBinding Controls:TextBoxHelper.ButtonWidth}"
Controls:TextBoxHelper.ButtonsAlignment="{TemplateBinding ButtonsAlignment}"
Controls:TextBoxHelper.ClearTextButton="{TemplateBinding Controls:TextBoxHelper.ClearTextButton}"
Controls:TextBoxHelper.HasText="{TemplateBinding Controls:TextBoxHelper.HasText}"
Controls:TextBoxHelper.SelectAllOnFocus="{TemplateBinding Controls:TextBoxHelper.SelectAllOnFocus}"
Controls:TextBoxHelper.UseFloatingWatermark="{TemplateBinding Controls:TextBoxHelper.UseFloatingWatermark}"
Controls:TextBoxHelper.Watermark="{TemplateBinding Controls:TextBoxHelper.Watermark}"
Controls:TextBoxHelper.WatermarkAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
Controls:TextBoxHelper.WatermarkTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}"
Background="{x:Null}"
BorderThickness="0"
FocusVisualStyle="{x:Null}"
Focusable="{TemplateBinding Focusable}"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
IsReadOnly="{TemplateBinding IsReadOnly}"
IsTabStop="{TemplateBinding IsTabStop}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TabIndex="{TemplateBinding TabIndex}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
<StackPanel x:Name="PART_Buttons"
Grid.Column="1"
Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:ThicknessSideType.Left}}"
Orientation="Horizontal">
<!-- down is now the first button -->
<RepeatButton x:Name="PART_NumericDown"
Width="{TemplateBinding UpDownButtonsWidth}"
VerticalContentAlignment="Center"
Delay="{TemplateBinding Delay}"
Foreground="{TemplateBinding Foreground}"
IsTabStop="False"
Style="{DynamicResource ChromelessButtonStyle}">
<Path x:Name="PolygonDown"
Width="14"
Height="3"
Data="F1 M 19,38L 57,38L 57,44L 19,44L 19,38 Z "
Fill="{DynamicResource GrayBrush1}"
Stretch="Fill" />
</RepeatButton>
<RepeatButton x:Name="PART_NumericUp"
Width="{TemplateBinding UpDownButtonsWidth}"
Delay="{TemplateBinding Delay}"
Foreground="{TemplateBinding Foreground}"
IsTabStop="False"
Style="{DynamicResource ChromelessButtonStyle}">
<Path x:Name="PolygonUp"
Width="14"
Height="14"
Data="F1 M 35,19L 41,19L 41,35L 57,35L 57,41L 41,41L 41,57L 35,57L 35,41L 19,41L 19,35L 35,35L 35,19 Z "
Fill="{DynamicResource GrayBrush1}"
Stretch="Fill" />
</RepeatButton>
</StackPanel>
</Grid>
<Border x:Name="DisabledVisualElement"
Background="{DynamicResource ControlsDisabledBrush}"
BorderBrush="{DynamicResource ControlsDisabledBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding Controls:ControlsHelper.CornerRadius}"
IsHitTestVisible="False"
Opacity="0"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.DisabledVisualElementVisibility), Mode=OneWay}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="ButtonsAlignment" Value="Left">
<Setter TargetName="PART_Buttons" Property="Grid.Column" Value="0" />
<Setter TargetName="PART_Buttons" Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:ThicknessSideType.Right}}" />
<Setter TargetName="PART_ButtonsColumn" Property="Width" Value="*" />
<Setter TargetName="PART_TextBox" Property="Grid.Column" Value="1" />
<Setter TargetName="PART_TextBox" Property="Margin" Value="-2 0 0 0" />
<Setter TargetName="PART_TextBox" Property="Margin" Value="-2 0 0 0" />
<Setter TargetName="PART_TextBoxColumn" Property="Width" Value="Auto" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="DisabledVisualElement" Property="Opacity" Value="0.6" />
</Trigger>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="InterceptArrowKeys" Value="False" />
<Setter Property="InterceptManualEnter" Value="False" />
<Setter Property="InterceptMouseWheel" Value="False" />
<Setter TargetName="PART_NumericDown" Property="IsEnabled" Value="False" />
<Setter TargetName="PART_NumericUp" Property="IsEnabled" Value="False" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsReadOnly" Value="False" />
<Condition Property="InterceptManualEnter" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="PART_TextBox" Property="IsReadOnly" Value="True" />
</MultiTrigger>
<Trigger SourceName="PART_NumericUp" Property="IsMouseOver" Value="True">
<Setter TargetName="PART_NumericUp" Property="Background" Value="{DynamicResource GrayBrush8}" />
<Setter TargetName="PolygonUp" Property="Fill" Value="{DynamicResource AccentColorBrush}" />
</Trigger>
<Trigger SourceName="PART_NumericUp" Property="IsPressed" Value="True">
<Setter TargetName="PART_NumericUp" Property="Background" Value="{DynamicResource BlackBrush}" />
<Setter TargetName="PolygonUp" Property="Fill" Value="{DynamicResource WhiteBrush}" />
</Trigger>
<Trigger SourceName="PART_NumericDown" Property="IsMouseOver" Value="True">
<Setter TargetName="PART_NumericDown" Property="Background" Value="{DynamicResource GrayBrush8}" />
<Setter TargetName="PolygonDown" Property="Fill" Value="{DynamicResource AccentColorBrush}" />
</Trigger>
<Trigger SourceName="PART_NumericDown" Property="IsPressed" Value="True">
<Setter TargetName="PART_NumericDown" Property="Background" Value="{DynamicResource BlackBrush}" />
<Setter TargetName="PolygonDown" Property="Fill" Value="{DynamicResource WhiteBrush}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Base" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.MouseOverBorderBrush)}" />
</Trigger>
<Trigger SourceName="PART_TextBox" Property="IsFocused" Value="true">
<Setter TargetName="Base" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.FocusBorderBrush)}" />
</Trigger>
<Trigger Property="HideUpDownButtons" Value="True">
<Setter TargetName="PART_Buttons" Property="Visibility" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

Related

How to apply a style to Combobox Template

I have a usercontrol which is multiselect combobox(i.e comoboxitems are checkboxes). I have a common style for every regular combo box in my application. The style is working fine for every combo box except the control I have created. When I comment out combobox template I am able to see the combobox style. The issue is incorporating combobox.template section and have the application style.
<!-- ComboBox -->
<Style x:Key="ComboBoxEditableTextBox" TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="{StaticResource Brush.Control.Background}" />
<!-- <Setter Property="CaretBrush" Value="White"/> -->
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground}" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="AllowDrop" Value="True" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="MinHeight" Value="0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Controls.FocusVisual}" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<ScrollViewer x:Name="PART_ContentHost"
Background="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Focusable="false"
Foreground="{TemplateBinding Foreground}"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden" />
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground.Highlighted}" />
</Trigger>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground.Disabled}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground.Disabled}" />
<Setter Property="Background" Value="{StaticResource Brush.Control.Background.Disabled}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Controls.ComboBox" TargetType="{x:Type ComboBox}">
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground}" />
<Setter Property="Background" Value="{StaticResource Brush.Control.Background}" />
<Setter Property="BorderBrush" Value="{StaticResource Brush.Control.Border}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="1" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Controls.FocusVisual}" />
<Setter Property="FontFamily" Value="MS Sans Serif" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="10pt" />
<Setter Property="IsTabStop" Value="True" />
<Setter Property="Code:ExtendedProperties.CornerRadius" Value="3" />
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Grid x:Name="grid" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Border x:Name="Bd"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="3,0,0,3"
Padding="1"
MinHeight="20">
<Border x:Name="SelectedItemBorder" Margin="{TemplateBinding Padding}" />
</Border>
<ContentPresenter x:Name="contentPresenter" Margin="3"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding SelectionBoxItem}"
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Visibility="Visible">
</ContentPresenter>
<TextBox x:Name="PART_EditableTextBox"
Margin="3"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontWeight="{TemplateBinding FontWeight}"
ContextMenu="{TemplateBinding ComboBox.ContextMenu}"
IsReadOnly="{Binding IsReadOnly,
RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ComboBoxEditableTextBox}"
Visibility="Collapsed" />
<!--<Path x:Name="DiffHighlighter" Visibility="Hidden" Data="M18.137,15.136 L18.137,3 C18.137,1.3431458 16.793854,0 15.137,0 L3,0 z" HorizontalAlignment="Right" Height="8.512" VerticalAlignment="Top" Width="8.513">
<Path.Fill>
<SolidColorBrush Color="{StaticResource quaBlueLightColor}" PresentationOptions:Freeze="true" />
</Path.Fill>
</Path>-->
<ToggleButton x:Name="transparentToggleButton"
IsChecked="{Binding IsDropDownOpen,
Mode=TwoWay,
RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource TransparentComboBoxButtonStyle}" />
<ToggleButton x:Name="dropDownToggleButton"
Grid.Column="1"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
BorderBrush="{TemplateBinding BorderBrush}"
IsChecked="{Binding IsDropDownOpen,
Mode=TwoWay,
RelativeSource={RelativeSource TemplatedParent}}"
RenderTransformOrigin="0.5,0.5"
Style="{StaticResource Controls.ComboBox.Button}"
Width="{Binding ActualHeight, ElementName=grid}"
Height="{Binding ActualHeight, ElementName=grid}">
<ToggleButton.RenderTransform>
<TranslateTransform X="-1" />
<!--<ScaleTransform CenterX="0.5"
CenterY="0.5"
ScaleX="1.1"
ScaleY="1.1" />-->
</ToggleButton.RenderTransform>
</ToggleButton>
<Popup x:Name="PART_Popup"
Grid.ColumnSpan="2"
AllowsTransparency="True"
Focusable="False"
IsOpen="{Binding IsDropDownOpen,
RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom">
<!--PopupAnimation="{StaticResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"-->
<Border MinWidth="{Binding ActualWidth,
ElementName=grid}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
Background="Transparent"
Padding="0 2 0 0">
<Border x:Name="DropDownBorder" BorderThickness="0">
<ScrollViewer x:Name="DropDownScrollViewer"
Code:ExtendedProperties.CornerRadius="{Binding Path=(Code:ExtendedProperties.CornerRadius),
RelativeSource={RelativeSource TemplatedParent}}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid Margin="3">
<Canvas Width="0"
Height="0"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Rectangle x:Name="OpaqueRect"
Width="{Binding ActualWidth,
ElementName=DropDownBorder}"
Height="{Binding ActualHeight,
ElementName=DropDownBorder}"
Fill="{Binding Background,
ElementName=DropDownBorder}" />
</Canvas>
<ItemsPresenter x:Name="ItemsPresenter"
KeyboardNavigation.DirectionalNavigation="Contained"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</ScrollViewer>
</Border>
</Border>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelectionBoxHighlighted" Value="True" />
<Condition Property="IsDropDownOpen" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground.Highlighted}" />
</MultiTrigger>
<Trigger Property="IsSelectionBoxHighlighted" Value="True">
<Setter TargetName="SelectedItemBorder" Property="Background" Value="{StaticResource Brush.Control.Background.Highlighted}" />
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground.HighlightedContrast}" />
</Trigger>
<Trigger Property="HasItems" Value="False">
<Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" />
</Trigger>
<!--<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground.Disabled}" />
<Setter TargetName="dropDownToggleButton" Property="Visibility" Value="Collapsed" />
<Setter TargetName="transparentToggleButton" Property="Visibility" Value="Collapsed" />
<Setter TargetName="SelectedItemBorder" Property="Visibility" Value="Collapsed" />
<Setter TargetName="Bd" Property="CornerRadius" Value="3" />
<Setter Property="IsHitTestVisible" Value="False" />
<Setter Property="IsTabStop" Value="False" />
</Trigger>-->
<Trigger Property="IsEditable" Value="True">
<Setter TargetName="SelectedItemBorder" Property="Visibility" Value="Collapsed" />
<Setter TargetName="contentPresenter" Property="Visibility" Value="Collapsed" />
<Setter TargetName="transparentToggleButton" Property="Visibility" Value="Collapsed" />
<Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="IsEditable" Value="False">
<Setter TargetName="SelectedItemBorder" Property="Visibility" Value="Visible" />
<Setter TargetName="contentPresenter" Property="Visibility" Value="Visible" />
<Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsGrouping" Value="True">
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
</Trigger>
<Trigger SourceName="DropDownScrollViewer" Property="ScrollViewer.CanContentScroll" Value="False">
<Setter TargetName="OpaqueRect" Property="Canvas.Top" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" />
<Setter TargetName="OpaqueRect" Property="Canvas.Left" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsReadOnly" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="BorderBrush" Value="{StaticResource Brush.Control.Border.Highlighted}" />
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground.Highlighted}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition SourceName="dropDownToggleButton" Property="IsMouseOver" Value="True" />
<Condition Property="IsReadOnly" Value="False" />
<Condition Property="IsEditable" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="BorderBrush" Value="{StaticResource Brush.Control.Border.Highlighted}" />
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground.Highlighted}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsReadOnly" Value="False" />
<Condition Property="IsEditable" Value="False" />
<Condition Property="IsSelectionBoxHighlighted" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="BorderBrush" Value="{StaticResource Brush.Control.Border.Highlighted}" />
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground.Highlighted}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsReadOnly" Value="False" />
<Condition Property="IsEditable" Value="False" />
<Condition Property="IsSelectionBoxHighlighted" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="BorderBrush" Value="{StaticResource Brush.Control.Border.Highlighted}" />
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground.HighlightedContrast}" />
</MultiTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{StaticResource Brush.Control.Foreground.Disabled}" />
<Setter Property="Background" Value="{StaticResource Brush.Control.Background.Disabled}" />
<Setter Property="BorderBrush" Value="{StaticResource Brush.Control.Border.Disabled}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<UserControl x:Class="MultiSelectComboBox.MultiSelectComboBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<ComboBox
x:Name="MultiSelectCombo"
Style="{StaticResource {x:Type ComboBox}}"
SnapsToDevicePixels="True"
OverridesDefaultStyle="True"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="True"
IsSynchronizedWithCurrentItem="True" >
<ComboBox.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding Title}"
IsChecked="{Binding Path=IsSelected, Mode=TwoWay}"
Tag="{RelativeSource FindAncestor, AncestorType={x:Type ComboBox}}"
Click="CheckBox_Click" />
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBox.Template >
<ControlTemplate TargetType="ComboBox" >
<Grid >
<ToggleButton
x:Name="ToggleButton"
BorderBrush="{TemplateBinding BorderBrush}"
Grid.Column="2"
IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
Focusable="false"
ClickMode="Press"
HorizontalContentAlignment="Left" >
<ToggleButton.Template>
<ControlTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="18"/>
</Grid.ColumnDefinitions>
<Border
x:Name="Border"
Grid.ColumnSpan="2"
CornerRadius="2"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" />
<Border
x:Name="BorderComp"
Grid.Column="0"
CornerRadius="2"
Margin="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" >
<TextBlock Text="{Binding Path=Text,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
Background="{TemplateBinding Background}" Padding="3" />
</Border>
<Path
x:Name="Arrow"
Grid.Column="1"
Fill="White"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 0 0 L 4 4 L 8 0 Z"/>
</Grid>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
<Popup
Name="Popup"
Placement="Bottom"
AllowsTransparency="True"
Focusable="False" IsOpen="{TemplateBinding IsDropDownOpen}"
PopupAnimation="Slide">
<Grid
Name="DropDown"
SnapsToDevicePixels="True"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border
x:Name="DropDownBorder"
BorderThickness="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"/>
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True" DataContext="{Binding}">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasItems" Value="false">
<Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/>
</Trigger>
<Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
<Setter TargetName="DropDownBorder" Property="CornerRadius" Value="4"/>
<Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ComboBox.Template>
</ComboBox>
</UserControl>
The expected result is that the combobox is supposed to take on the style that is in the application which is the all black combobox

WPF - "g" is cut off sometimes

I have a combobox in which I display simple strings. At some point this looks like the following:
This is ok. now ein scroll down one step:
Now the "g" is cut off at the bottom. What I have tried so far: Set the height property explicit to Auto. Changing Padding and Margin. Nothing worked. Had some of you the same problem or any suggestions what I could try?
EDIT
Here the related XAML:
<Style x:Key="GraphicEditorInplaceLabelEditStyle">
<Setter Property="ComboBox.Focusable" Value="True"/>
<Setter Property="ComboBox.IsEditable" Value="True"/>
<Setter Property="ComboBox.IsReadOnly" Value="False"/>
<Setter Property="ComboBox.IsTextSearchEnabled" Value="True"/>
<!--Use Separators for empty entries-->
<Setter Property="ComboBox.ItemContainerStyle">
<Setter.Value>
<Style TargetType="{x:Type ComboBoxItem}" BasedOn="{StaticResource {x:Type ComboBoxItem}}">
<Style.Triggers>
<DataTrigger Binding="{Binding}" Value="">
<Setter Property="IsEnabled" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Separator HorizontalAlignment="Stretch"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Setter.Value>
</Setter>
<Setter Property="ComboBox.Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border Validation.ValidationAdornerSiteFor="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType=ComboBox}}" Background="{StaticResource ComboBoxActiveBackgroundBrush}" BorderBrush="{StaticResource ComboBoxBorderBrush}" BorderThickness="1" CornerRadius="2">
<Grid>
<ContentPresenter Margin="3,3,3,3" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" HorizontalAlignment="Left" IsHitTestVisible="False" Name="ContentSite" VerticalAlignment="Center" />
<TextBlock Style="{x:Null}" x:Name="PART_TextBackground" Margin="3,3,3,3" Background="Transparent" Focusable="False" FontStyle="Italic" Foreground="LightGray" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<TextBox Style="{x:Null}" x:Name="PART_EditableTextBox" Margin="3,3,3,3" Background="Transparent" Focusable="True" HorizontalAlignment="Left" IsReadOnly="{TemplateBinding IsReadOnly}" VerticalAlignment="Center" Visibility="Hidden">
<TextBox.Template>
<ControlTemplate TargetType="TextBox">
<Border x:Name="PART_ContentHost" Background="{TemplateBinding Background}" Focusable="False" />
</ControlTemplate>
</TextBox.Template>
</TextBox>
<Popup AllowsTransparency="True" Focusable="False" IsOpen="{TemplateBinding IsDropDownOpen}" Name="Popup" Placement="Bottom" PopupAnimation="Slide">
<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" Name="DropDown" SnapsToDevicePixels="True">
<Border x:Name="DropDownBorder" Background="{StaticResource ComboBoxActiveBackgroundBrush}" BorderBrush="{StaticResource ComboBoxBorderBrush}" BorderThickness="1" />
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True" CanContentScroll="False">
<StackPanel KeyboardNavigation.DirectionalNavigation="Contained" IsItemsHost="True" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
</Border>
<ToggleButton Grid.Column="1" ClickMode="Press" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" Name="ToggleButton" VerticalAlignment="Bottom">
<ToggleButton.Template>
<ControlTemplate TargetType="ToggleButton">
<Grid>
<Border x:Name="Border"
CornerRadius="2"
Background="{StaticResource ComboBoxActiveBackgroundBrush}"
BorderBrush="{StaticResource ComboBoxBorderBrush}"
BorderThickness="1"
Margin="0,0,0,0" />
<Rectangle x:Name="arrow"
Height="6"
Width="8"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="2"
Fill="{StaticResource ComboBoxArrowDownBrush}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="ToggleButton.IsMouseOver"
Value="true">
<Setter TargetName="Border"
Property="Background"
Value="{StaticResource ComboBoxMouseOverBackgroundBrush}" />
<Setter TargetName="arrow"
Property="Fill"
Value="{StaticResource ComboBoxArrowDownMouseOverBrush}"></Setter>
</Trigger>
<Trigger Property="ToggleButton.IsChecked"
Value="true">
<Setter TargetName="Border"
Property="Background"
Value="{StaticResource ComboBoxPressedBackgroundBrush}" />
<Setter Property="Fill"
TargetName="arrow"
Value="{StaticResource ComboBoxArrowUpBrush}" />
</Trigger>
<Trigger Property="IsEnabled"
Value="false">
<Setter TargetName="Border"
Property="Background"
Value="{StaticResource ComboBoxInactiveBackgroundBrush}" />
<Setter Property="Foreground"
Value="{StaticResource FontInactiveBrush}" />
<Setter Property="Fill"
TargetName="arrow"
Value="{StaticResource ComboBoxArrowDownInactiveBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ToggleButton.Template>
<ToggleButton.RenderTransform>
<TranslateTransform X="-3" Y="0"></TranslateTransform>
</ToggleButton.RenderTransform>
</ToggleButton>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasItems" Value="false">
<Setter Property="Visibility" TargetName="ToggleButton" Value="Collapsed" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{StaticResource FontInactiveBrush}" />
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
</Trigger>
<Trigger Property="Popup.AllowsTransparency" SourceName="Popup" Value="true">
<Setter Property="CornerRadius" TargetName="DropDownBorder" Value="4" />
<Setter Property="Margin" TargetName="DropDownBorder" Value="0,2,0,0" />
</Trigger>
<Trigger Property="IsEditable" Value="true">
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Visibility" TargetName="PART_EditableTextBox" Value="Visible" />
<Setter Property="Visibility" TargetName="ContentSite" Value="Hidden" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I tried to change the padding/margin of the ComboBoxItem as well as the item host stackpanel.

System.Windows.Controls.MenuItem without icon area

Whenever I try to play with the look of WPF menu item, I get a wast opportunities to customize the header, which is basically the text of an item.
What I need, is to have a black menu, with white text and no "icon area".
||Some text http://img848.imageshack.us/img848/7622/iconarea.png
How can I remove the icon area of the menu item?
Thanks.
You can achieve it by defining ItemsPanel property of MenuItem.
Create an ItemsPanelTemplate resource
<ItemsPanelTemplate x:Key="MenuItemPanelTemplate">
<StackPanel Margin="-20,0,0,0" Background="White"/>
</ItemsPanelTemplate>
Add below MenuItem style to resources and you are done.
<Style TargetType="{x:Type MenuItem}">
<Setter Property="ItemsPanel" Value="{StaticResource MenuItemPanelTemplate}"/>
</Style>
To apply same Style to a ContextMenu, you need to create one more Style as following-
<Style TargetType="{x:Type ContextMenu}">
<Setter Property="ItemsPanel" Value="{StaticResource MenuItemPanelTemplate}"/>
</Style>
You would need to take the default Styles from here and remove that area from the MenuItem's control template.
For MenuItem, you can actually just redefine the SubmenuItemTemplateKey and SubmenuHeaderTemplateKey ControlTemplate, something like described here.
EDIT:
The background is actually rendered by the Menu Style. If you search for "MenuItemIconColumnGroup", you will find all the places that use it.
EDIT:
Here is a complete sample that uses a Black background and White foreground:
<Application x:Class="DeleteMeWPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
StartupUri="MainWindow.xaml">
<Application.Resources>
<MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter" />
<Geometry x:Key="DownArrow">M 0,0 L 3.5,4 L 7,0 Z</Geometry>
<Geometry x:Key="UpArrow">M 0,4 L 3.5,0 L 7,4 Z</Geometry>
<Geometry x:Key="RightArrow">M 0,0 L 4,3.5 L 0,7 Z</Geometry>
<Geometry x:Key="Checkmark">M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z</Geometry>
<LinearGradientBrush x:Key="MenuItemSelectionFill" StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#34C5EBFF" Offset="0" />
<GradientStop Color="#3481D8FF" Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="MenuItemPressedFill" StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#28717070" Offset="0" />
<GradientStop Color="#50717070" Offset="0.75" />
<GradientStop Color="#90717070" Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Separator}">
<Grid SnapsToDevicePixels="true" Margin="0,6,0,4">
<Rectangle Height="1" Margin="30,0,1,1" Fill="#E0E0E0" />
<Rectangle Height="1" Margin="30,1,1,0" Fill="White" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=SubmenuContent}"
TargetType="{x:Type ContentControl}">
<Border Background="Black" BorderBrush="#FF959595" BorderThickness="1">
<ContentPresenter Grid.ColumnSpan="2" Margin="1,0" />
</Border>
</ControlTemplate>
<ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelItemTemplateKey}"
TargetType="{x:Type MenuItem}">
<Grid SnapsToDevicePixels="true">
<Rectangle x:Name="OuterBorder" RadiusX="2" RadiusY="2" />
<Rectangle Name="Bg" Margin="1" Fill="{TemplateBinding MenuItem.Background}" Stroke="{TemplateBinding MenuItem.BorderBrush}"
StrokeThickness="1" RadiusX="1" RadiusY="1" />
<Rectangle x:Name="InnerBorder" Margin="2" />
<DockPanel>
<ContentPresenter x:Name="Icon" Margin="4,0,6,0" VerticalAlignment="Center" ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Path x:Name="GlyphPanel" Margin="7,0,0,0" Visibility="Collapsed" VerticalAlignment="Center"
Fill="{TemplateBinding MenuItem.Foreground}" FlowDirection="LeftToRight" Data="{StaticResource Checkmark}" />
<ContentPresenter ContentSource="Header" Margin="{TemplateBinding MenuItem.Padding}" RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</DockPanel>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsHighlighted" Value="true">
<Setter TargetName="Bg" Property="Stroke" Value="#90717070" />
<Setter TargetName="OuterBorder" Property="Stroke" Value="#50FFFFFF" />
<Setter TargetName="InnerBorder" Property="Stroke" Value="#50FFFFFF" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter TargetName="Bg" Property="Stroke" Value="#E0717070" />
<Setter TargetName="Bg" Property="Fill" Value="{StaticResource MenuItemPressedFill}" />
<Setter TargetName="InnerBorder" Property="Stroke" Value="#50747272" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#FF9A9A9A" />
<Setter TargetName="GlyphPanel" Property="Fill" Value="#848589" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelHeaderTemplateKey}"
TargetType="{x:Type MenuItem}">
<Grid SnapsToDevicePixels="true">
<Rectangle x:Name="OuterBorder" RadiusX="2" RadiusY="2" />
<Rectangle Name="Bg" Margin="1" Fill="{TemplateBinding MenuItem.Background}" Stroke="{TemplateBinding MenuItem.BorderBrush}"
StrokeThickness="1" RadiusX="1" RadiusY="1" />
<Rectangle x:Name="InnerBorder" Margin="2" />
<DockPanel>
<ContentPresenter x:Name="Icon" Margin="4,0,6,0" VerticalAlignment="Center" ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Path x:Name="GlyphPanel" Margin="7,0,0,0" Visibility="Collapsed" VerticalAlignment="Center"
Fill="{TemplateBinding MenuItem.Foreground}" FlowDirection="LeftToRight" Data="{StaticResource Checkmark}" />
<ContentPresenter ContentSource="Header" Margin="{TemplateBinding MenuItem.Padding}" RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</DockPanel>
<Popup x:Name="PART_Popup" HorizontalOffset="1" VerticalOffset="-1" AllowsTransparency="true" Placement="Bottom"
IsOpen="{Binding Path=IsSubmenuOpen,RelativeSource={RelativeSource TemplatedParent}}" Focusable="false"
PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
<theme:SystemDropShadowChrome Name="Shdw" Color="Transparent">
<ContentControl Name="SubMenuBorder"
Template="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=SubmenuContent}}"
IsTabStop="false">
<ScrollViewer CanContentScroll="true"
Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}">
<ItemsPresenter Margin="2" KeyboardNavigation.TabNavigation="Cycle"
KeyboardNavigation.DirectionalNavigation="Cycle"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.IsSharedSizeScope="true" />
</ScrollViewer>
</ContentControl>
</theme:SystemDropShadowChrome>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSuspendingPopupAnimation" Value="true">
<Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger SourceName="PART_Popup" Property="Popup.HasDropShadow" Value="true">
<Setter TargetName="Shdw" Property="Margin" Value="0,0,5,5" />
<Setter TargetName="Shdw" Property="Color" Value="#71000000" />
</Trigger>
<Trigger Property="IsHighlighted" Value="true">
<Setter TargetName="Bg" Property="Stroke" Value="#90717070" />
<Setter TargetName="OuterBorder" Property="Stroke" Value="#50FFFFFF" />
<Setter TargetName="InnerBorder" Property="Stroke" Value="#50FFFFFF" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter TargetName="Bg" Property="Stroke" Value="#E0717070" />
<Setter TargetName="Bg" Property="Fill" Value="{StaticResource MenuItemPressedFill}" />
<Setter TargetName="InnerBorder" Property="Stroke" Value="#50747272" />
</Trigger>
<Trigger Property="IsSubmenuOpen" Value="true">
<Setter TargetName="Bg" Property="Stroke" Value="#E0717070" />
<Setter TargetName="Bg" Property="Fill" Value="{StaticResource MenuItemPressedFill}" />
<Setter TargetName="InnerBorder" Property="Stroke" Value="#50747272" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#FF9A9A9A" />
<Setter TargetName="GlyphPanel" Property="Fill" Value="#848589" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuItemTemplateKey}"
TargetType="{x:Type MenuItem}">
<Grid SnapsToDevicePixels="true">
<Rectangle Name="Bg" Fill="{TemplateBinding MenuItem.Background}" Stroke="{TemplateBinding MenuItem.BorderBrush}"
StrokeThickness="1" RadiusX="2" RadiusY="2" />
<Rectangle x:Name="InnerBorder" Margin="1" RadiusX="2" RadiusY="2" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup" />
<ColumnDefinition Width="4" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="37" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
<ColumnDefinition Width="17" />
</Grid.ColumnDefinitions>
<ContentPresenter x:Name="Icon" Margin="1" VerticalAlignment="Center" ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Border x:Name="GlyphPanel" Background="#E6EFF4" BorderBrush="#CDD3E6" BorderThickness="1" CornerRadius="3" Margin="1"
Visibility="Collapsed" Width="22" Height="22">
<Path Name="Glyph" Width="9" Height="11" Fill="#0C12A1" FlowDirection="LeftToRight"
Data="{StaticResource Checkmark}" />
</Border>
<ContentPresenter Grid.Column="2" ContentSource="Header" Margin="{TemplateBinding MenuItem.Padding}"
RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<TextBlock Grid.Column="4" Text="{TemplateBinding MenuItem.InputGestureText}"
Margin="{TemplateBinding MenuItem.Padding}" />
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsHighlighted" Value="true">
<Setter TargetName="Bg" Property="Fill" Value="{StaticResource MenuItemSelectionFill}" />
<Setter TargetName="Bg" Property="Stroke" Value="#8071CBF1" />
<Setter TargetName="InnerBorder" Property="Stroke" Value="#40FFFFFF" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#FF9A9A9A" />
<Setter TargetName="GlyphPanel" Property="Background" Value="#EEE9E9" />
<Setter TargetName="GlyphPanel" Property="BorderBrush" Value="#DBD6D6" />
<Setter TargetName="Glyph" Property="Fill" Value="#848589" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuHeaderTemplateKey}"
TargetType="{x:Type MenuItem}">
<Grid SnapsToDevicePixels="true">
<Rectangle Name="Bg" Fill="{TemplateBinding MenuItem.Background}" Stroke="{TemplateBinding MenuItem.BorderBrush}"
StrokeThickness="1" RadiusX="2" RadiusY="2" />
<Rectangle x:Name="InnerBorder" Margin="1" Stroke="Transparent" StrokeThickness="1" RadiusX="2" RadiusY="2" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup" />
<ColumnDefinition Width="4" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="37" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
<ColumnDefinition Width="17" />
</Grid.ColumnDefinitions>
<ContentPresenter x:Name="Icon" Margin="1" VerticalAlignment="Center" ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Border x:Name="GlyphPanel" Background="#E6EFF4" BorderBrush="#CDD3E6" BorderThickness="1" CornerRadius="3" Margin="1"
Visibility="Collapsed" Width="22" Height="22">
<Path Name="Glyph" Width="9" Height="11" Fill="#0C12A1" FlowDirection="LeftToRight"
Data="{StaticResource Checkmark}" />
</Border>
<ContentPresenter Grid.Column="2" ContentSource="Header" Margin="{TemplateBinding MenuItem.Padding}"
RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<TextBlock Grid.Column="4" Text="{TemplateBinding MenuItem.InputGestureText}"
Margin="{TemplateBinding MenuItem.Padding}" Visibility="Collapsed" />
<Path Grid.Column="5" VerticalAlignment="Center" Margin="4,0,0,0" Fill="{TemplateBinding MenuItem.Foreground}"
Data="{StaticResource RightArrow}" />
</Grid>
<Popup x:Name="PART_Popup" AllowsTransparency="true" Placement="Right" VerticalOffset="-3" HorizontalOffset="-2"
IsOpen="{Binding Path=IsSubmenuOpen,RelativeSource={RelativeSource TemplatedParent}}" Focusable="false"
PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
<theme:SystemDropShadowChrome Name="Shdw" Color="Transparent">
<ContentControl Name="SubMenuBorder"
Template="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=SubmenuContent}}"
IsTabStop="false">
<ScrollViewer CanContentScroll="true"
Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}">
<ItemsPresenter Margin="2" KeyboardNavigation.TabNavigation="Cycle"
KeyboardNavigation.DirectionalNavigation="Cycle"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.IsSharedSizeScope="true" />
</ScrollViewer>
</ContentControl>
</theme:SystemDropShadowChrome>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSuspendingPopupAnimation" Value="true">
<Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
</Trigger>
<Trigger Property="IsHighlighted" Value="true">
<Setter TargetName="InnerBorder" Property="Stroke" Value="#D1DBF4FF" />
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger SourceName="PART_Popup" Property="Popup.HasDropShadow" Value="true">
<Setter TargetName="Shdw" Property="Margin" Value="0,0,5,5" />
<Setter TargetName="Shdw" Property="Color" Value="#71000000" />
</Trigger>
<Trigger Property="IsHighlighted" Value="true">
<Setter TargetName="Bg" Property="Fill" Value="{StaticResource MenuItemSelectionFill}" />
<Setter TargetName="Bg" Property="Stroke" Value="#8571CBF1" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#FF9A9A9A" />
<Setter TargetName="GlyphPanel" Property="Background" Value="#EEE9E9" />
<Setter TargetName="GlyphPanel" Property="BorderBrush" Value="#DBD6D6" />
<Setter TargetName="Glyph" Property="Fill" Value="#848589" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="HorizontalContentAlignment"
Value="{Binding Path=HorizontalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="VerticalContentAlignment"
Value="{Binding Path=VerticalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template"
Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuItemTemplateKey}}" />
<Style.Triggers>
<Trigger Property="Role" Value="TopLevelHeader">
<Setter Property="Padding" Value="7,2,8,3" />
<Setter Property="Template"
Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelHeaderTemplateKey}}" />
</Trigger>
<Trigger Property="Role" Value="TopLevelItem">
<Setter Property="Padding" Value="7,2,8,3" />
<Setter Property="Template"
Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=TopLevelItemTemplateKey}}" />
</Trigger>
<Trigger Property="Role" Value="SubmenuHeader">
<Setter Property="Padding" Value="2,3,2,3" />
<Setter Property="Template"
Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type MenuItem}, ResourceId=SubmenuHeaderTemplateKey}}" />
</Trigger>
<Trigger Property="Role" Value="SubmenuItem">
<Setter Property="Padding" Value="2,3,2,3" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type Menu}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Background" Value="Black" />
<Setter Property="FontFamily" Value="{DynamicResource {x:Static SystemFonts.MenuFontFamilyKey}}" />
<Setter Property="FontSize" Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}" />
<Setter Property="FontStyle" Value="{DynamicResource {x:Static SystemFonts.MenuFontStyleKey}}" />
<Setter Property="FontWeight" Value="{DynamicResource {x:Static SystemFonts.MenuFontWeightKey}}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Menu}">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
</Application>
The solution which overrides the Template seems to be overkill (for me), the other answer from 'nits' is cool, but the selection overlay is not drawn correct (in my example).
My aim was to use the space of the icon and the space of the shortcut.
This is the result:
Here the code:
<ContextMenu ItemsSource="{Binding MyItems}" >
<ContextMenu.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Background="White"></StackPanel>
</ItemsPanelTemplate>
</ContextMenu.ItemsPanel>
<ContextMenu.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Command" Value="{Binding Path=DataContext.XyzCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
<Setter Property="CommandParameter" Value="{Binding}"/>
</Style>
</ContextMenu.ItemContainerStyle>
<ContextMenu.ItemTemplate>
<DataTemplate>
<Grid Margin="-20,0,-40,0"><!--this part is important-->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Ident}"/>
<TextBlock Grid.Column="1" Text="{Binding Description}"/>
</Grid>
</DataTemplate>
</ContextMenu.ItemTemplate>
-20 uses the space of the Icon, -40 uses the space of the shortcut. Furthermore the size of the popup is calculated automatically in this example.
Also worth to mention is the binding of the command: all items are bound to the same command, but the item itself is given as the Parameter of the Event (CommandParameter).
public ViewModel()
{
XyzCommand = new DelegateCommand<Item>(XyzCommandExecute);
}
private void XyzCommandExecute(Item item)
{
//command code
}

WPF - styling comboboxes

I'm trying to style Comboboxes in WPF so that they are white, and have the same border as TextBoxes. I have the following style so far, but don't know how to set the border:
<Style TargetType="ComboBox">
<Setter Property="Margin" Value="0,2,0,2" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Background" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
???
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Use Expression Blend. If you want ComboBox to look similar to TextBox, have a look at TextBox template by right clicking TextBlock and selecting Edit Template > Edit a Copy and use that to modify your ComboBox template!
In between your controltemplate please implement something like this:
<Grid SnapsToDevicePixels="true">
<Border
x:Name="Bd"
Background="Transparent"
BorderBrush="#FF888888"
Padding="1"
CornerRadius="5" BorderThickness="2,2,2,2">
<Grid
Grid.IsSharedSizeScope="true">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto"
SharedSizeGroup="ComboBoxButton" />
</Grid.ColumnDefinitions>
<Border x:Name="SelectedItemBorder" Grid.ColumnSpan="2" />
<ContentPresenter
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Grid.Column="1"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
TextBlock.Foreground="White"
Height="Auto"
Margin="2,2,7,2"
VerticalAlignment="Center" />
<ToggleButton
Style="{StaticResource ComboBoxTransparentButtonStyle}"
Grid.ColumnSpan="3"
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay,
RelativeSource={RelativeSource TemplatedParent}}"
Opacity="0.25" />
</Grid>
</Border>
<Popup Focusable="false" AllowsTransparency="true"
IsOpen="{Binding Path=IsDropDownOpen,
RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom"
PopupAnimation="{DynamicResource
{x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
x:Name="PART_Popup">
<Border CornerRadius="5" x:Name="DropDownBorder"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
MinWidth="{TemplateBinding ActualWidth}"
Background="#FF7E7E7E"
BorderThickness="1">
<ScrollViewer Foreground="#FFFFFFFF">
<ItemsPresenter
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
KeyboardNavigation.DirectionalNavigation="Contained"
TextBlock.Foreground="White"
VerticalAlignment="Stretch" />
</ScrollViewer>
</Border>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" TargetName="Bd" Value="#FFFFFFFF"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" TargetName="Bd" Value="#FFD2ECCF"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelectionBoxHighlighted" Value="true" />
<Condition Property="IsDropDownOpen" Value="false" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="white" />
<Setter Property="BorderBrush" Value="{x:Null}" />
</MultiTrigger>
<Trigger Property="IsSelectionBoxHighlighted" Value="true">
<Setter Property="Background" TargetName="SelectedItemBorder"
Value="Transparent" />
</Trigger>
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter Property="MinHeight" TargetName="DropDownBorder" Value="95" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground"
Value="{DynamicResource
{x:Static SystemColors.GrayTextBrushKey}}" />
<Setter Property="Background" TargetName="Bd"
Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
</Trigger>
</ControlTemplate.Triggers>

ComboBox Style problems with DisplayMemberPath

I have a ComboBox and I have set the combo.ItemsSource property to a List object. The Book class contains two properties: "Abbreviation" and "Name".
I have set the ComboBox's DisplayMemberPath to "Abbreviation" but the following style that is set on the ComboBox does not display the Abbreviation property, but instead shows "Words.Book" which is the name of the class. The ComboBox drop-down displays a list correctly (Using the specified Abbreviation property). The problem is in the selected ComboBox item, the one displayed when the ComboBox' drop-down is closed.
I guess the problem is in ContentPresenter in DataTemplate but I was unable to find a successful solution. Currently the ContentPresenter's Content property is set to Content="{TemplateBinding Content} but I don't know if that's how it should be.
Any ideas how to show the property specified in DisplayMemberPath on the selected item?
Thank you
the code:
<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<Border x:Name="Border" Grid.ColumnSpan="2" CornerRadius="2" BorderThickness="1" Background="{DynamicResource ribbonTitleFade}" />
<Border Grid.Column="0" CornerRadius="2,0,0,2" Margin="1,6,1,6" BorderBrush="{DynamicResource boSecE}" BorderThickness="0,0,1,0" />
<Path x:Name="Arrow" Grid.Column="1" Fill="White"
HorizontalAlignment="Center" VerticalAlignment="Center" Data="M 0 0 L 4 4 L 8 0 Z"
/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="ToggleButton.IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ribbonTitleFade}" />
</Trigger>
<Trigger Property="ToggleButton.IsChecked" Value="true">
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ribbonTitleFade}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Border" Property="Background" Value="Black" />
<Setter TargetName="Border" Property="BorderBrush" Value="Black" />
<Setter Property="Foreground" Value="Gray"/>
<Setter TargetName="Arrow" Property="Fill" Value="Gray" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="comboBoxBorderTransparent" TargetType="Control">
<Setter Property="BorderBrush" Value="{DynamicResource boPrimC}" />
</Style>
<Style x:Key="comboItemStyle" TargetType="ComboBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border x:Name="backBorder" >
<StackPanel Orientation="Horizontal">
<Rectangle x:Name="rectA" Stroke="White" Width="4" Height="4" Fill="#80FFFFFF" Margin="5,0,0,0" HorizontalAlignment="Left" />
<TextBlock x:Name="text" Foreground="White" FontSize="10px">
<ContentPresenter Margin="8,1,0,1"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
/>
</TextBlock>
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="ComboBoxItem.IsMouseOver" Value="true">
<Setter TargetName="rectA" Property="Stroke" Value="Black" />
<Setter TargetName="rectA" Property="Fill" Value="#80000000" />
<Setter TargetName="backBorder" Property="Background" Value="White"/>
<Setter TargetName="text" Property="Foreground" Value="{DynamicResource boPrimC}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="comboSelectedItemTemplate">
<TextBlock Foreground="White" FontSize="10px">
<ContentPresenter Content="{TemplateBinding Content}" />
</TextBlock>
</DataTemplate>
<Style TargetType="ComboBox">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="MinWidth" Value="60"/>
<Setter Property="MinHeight" Value="20"/>
<Setter Property="ItemContainerStyle" Value="{DynamicResource comboItemStyle}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<ToggleButton
Name="ToggleButton" Grid.Column="2"
Template="{StaticResource ComboBoxToggleButton}"
Focusable="false"
IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
ClickMode="Press">
</ToggleButton>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"
Name="ContentSite"
IsHitTestVisible="False"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{DynamicResource comboSelectedItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
Margin="3,3,23,3"
/>
<Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}"
AllowsTransparency="False" Focusable="False" PopupAnimation="Slide">
<Grid Name="DropDown" SnapsToDevicePixels="True"
MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border x:Name="DropDownBorder" Background="{DynamicResource ribbonTitleFade}"
BorderThickness="1" BorderBrush="{DynamicResource boPrimC}" />
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasItems" Value="false">
<Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="Black"/>
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</Trigger>
<Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
<Setter TargetName="DropDownBorder" Property="CornerRadius" Value="2"/>
<Setter TargetName="DropDownBorder" Property="Margin" Value="0"/>
</Trigger>
<Trigger Property="IsEditable" Value="true">
<Setter Property="IsTabStop" Value="false"/>
<!--<Setter TargetName="ContentSite" Property="Visibility" Value="Hidden"/>-->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
</Style.Triggers>
</Style>
I think you want something more like this in your ComboBox template:
<ContentPresenter Content="{TemplateBinding ComboBox.SelectionBoxItem}"
ContentTemplate="{TemplateBinding ComboBox.SelectionBoxItemTemplate}"
ContentStringFormat="{TemplateBinding ComboBox.SelectionBoxItemStringFormat}"
Margin="{TemplateBinding Control.Padding}"
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
If your template doesn't explicitly handles the value of DisplayMemberPath, then the template won't use it to change the ComboBoxItem. You'll have to bind to the member directly in the ControlTemplate, or use a separate DataTemplate.
I found problem with the BureauBlack theme where it would just not apply the DisplayMemberPath, just showed the object name. I had a window with many (15+) ComboBoxes and all but 2 worked correctly using DisplayMemberPath.
I removed the following from the ContentPresenters and GridViewRowPresenters:
Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"
in ListBoxItem, ComboBoxItem,ListViewItem. There may be more that need fixed, but this was all we found that we are using.
Using Microsoft.Net 4.0 Framework. I did not try on 4.5 or 3.5.

Resources