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
Related
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>
Hi I need to change the look of RibbonMenuButton, but I am not able to find its style, part or template on internet. Neither I am able to generate a copy from blend or vs designer. So if anyone has its control template please share
You can use ILSpy (an open-source .NET assembly browser and decompiler) for exploring an assembly and - in your case - for exploring resources that contain - for example - a style.
By using this tool, you will find that the generic style of a RibbonMenuButton in the RibbonControlsLibrary.dll (version 4.0.0.11019) is (I cut and past it for your convenience):
<Style x:Key="{x:Type ribbon:RibbonMenuButton}" TargetType="{x:Type ribbon:RibbonMenuButton}">
<Style.Resources>
<Style TargetType="{x:Type ribbon:RibbonSeparator}">
<Setter Property="FrameworkElement.OverridesDefaultStyle" Value="True" />
<Setter Property="UIElement.Focusable" Value="False" />
<Setter Property="Control.BorderBrush" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ribbon:RibbonMenuButton}}, Path=Ribbon.BorderBrush}" />
<Setter Property="Control.Background" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ribbon:RibbonMenuButton}}, Path=Ribbon.Background}" />
<Setter Property="Control.FontWeight" Value="Bold" />
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ribbon:RibbonSeparator}">
<Border Name="MainBorder" SnapsToDevicePixels="True" BorderThickness="0,1,0,1" BorderBrush="{TemplateBinding Control.BorderBrush}" Background="{TemplateBinding Control.Background}">
<Border Name="Overlay" Background="{StaticResource ä}">
<TextBlock Name="Text" Margin="2,1,2,1" Text="{TemplateBinding ribbon:RibbonSeparator.Label}" />
</Border>
</Border>
<ControlTemplate.Triggers>
<DataTrigger Value="True" Binding="{Binding Path=HighContrast, Source={x:Static shell:SystemParameters2.Current}}">
<Setter TargetName="Text" Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}" Property="TextBlock.Foreground" />
<Setter TargetName="Overlay" Property="Border.Background" Value="#00FFFFFF" />
<Setter TargetName="MainBorder" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" Property="Border.BorderBrush" />
<Setter TargetName="MainBorder" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Property="Border.Background" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="ribbon:RibbonSeparator.Label" Value="{x:Null}">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ribbon:RibbonSeparator}">
<Grid Name="Grid" SnapsToDevicePixels="True" Margin="1">
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="22" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="14" />
</Grid.ColumnDefinitions>
<Border Name="SideBarBorder" BorderThickness="0,0,1,0" Margin="0,-1,0,-1" Background="{TemplateBinding Control.Background}" BorderBrush="{TemplateBinding Control.BorderBrush}">
<Border Name="SideBarOverlay" Background="{StaticResource ä}" />
</Border>
<Line Name="Line" Grid.Column="1" Grid.ColumnSpan="2" Margin="2,0,0,0" X1="0" Y1="0" X2="1" Y2="0" Stroke="{TemplateBinding Control.BorderBrush}" StrokeThickness="1" Stretch="Fill" />
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Value="True" Binding="{Binding Path=HighContrast, Source={x:Static shell:SystemParameters2.Current}}">
<Setter TargetName="SideBarBorder" Property="Border.Background" Value="#00FFFFFF" />
<Setter TargetName="SideBarBorder" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" Property="Border.BorderBrush" />
<Setter TargetName="SideBarOverlay" Property="Border.Background" Value="#00FFFFFF" />
<Setter TargetName="Line" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" Property="Shape.Stroke" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</Style.Resources>
<Setter Property="Control.Background" Value="#00FFFFFF" />
<Setter Property="Control.BorderBrush" Value="#00FFFFFF" />
<Setter Property="Control.BorderThickness" Value="1" />
<Setter Property="FrameworkElement.FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Control.HorizontalContentAlignment" Value="Center" />
<Setter Property="Control.Padding" Value="2,0,2,0" />
<Setter Property="ribbon:RibbonMenuButton.MouseOverBorderBrush" Value="{Binding RelativeSource={RelativeSource Self}, Path=Ribbon.MouseOverBorderBrush}" />
<Setter Property="ribbon:RibbonMenuButton.MouseOverBackground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Ribbon.MouseOverBackground}" />
<Setter Property="ribbon:RibbonMenuButton.PressedBorderBrush" Value="{Binding RelativeSource={RelativeSource Self}, Path=Ribbon.PressedBorderBrush}" />
<Setter Property="ribbon:RibbonMenuButton.PressedBackground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Ribbon.PressedBackground}" />
<Setter Property="ribbon:RibbonMenuButton.FocusedBorderBrush" Value="{Binding RelativeSource={RelativeSource Self}, Path=Ribbon.FocusedBorderBrush}" />
<Setter Property="ribbon:RibbonMenuButton.FocusedBackground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Ribbon.FocusedBackground}" />
<Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource à}" />
<Setter Property="ToolTipService.ShowDuration" Value="{StaticResource á}" />
<Setter Property="ToolTipService.BetweenShowDelay" Value="{StaticResource â}" />
<Setter Property="ribbon:RibbonTwoLineText.PathData" Value="{StaticResource ÿ}" />
<Setter Property="ribbon:RibbonMenuButton.QuickAccessToolBarControlSizeDefinition">
<Setter.Value>
<rcp:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="False" />
</Setter.Value>
</Setter>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ribbon:RibbonMenuButton}">
<Grid Name="MainGrid" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<rcp:RibbonToggleButton x:Name="PART_ToggleButton" Template="{StaticResource Ĥ}" RibbonTwoLineText.PathData="{TemplateBinding ribbon:RibbonTwoLineText.PathData}" Label="{TemplateBinding ribbon:RibbonMenuButton.Label}" LargeImageSource="{TemplateBinding ribbon:RibbonMenuButton.LargeImageSource}" SmallImageSource="{TemplateBinding ribbon:RibbonMenuButton.SmallImageSource}" ControlSizeDefinition="{TemplateBinding ribbon:RibbonMenuButton.ControlSizeDefinition}" BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="{TemplateBinding Control.BorderThickness}" Background="{TemplateBinding Control.Background}" CornerRadius="2" MouseOverBorderBrush="{TemplateBinding ribbon:RibbonMenuButton.MouseOverBorderBrush}" MouseOverBackground="{TemplateBinding ribbon:RibbonMenuButton.MouseOverBackground}" CheckedBorderBrush="{TemplateBinding ribbon:RibbonMenuButton.PressedBorderBrush}" CheckedBackground="{TemplateBinding ribbon:RibbonMenuButton.PressedBackground}" FocusedBorderBrush="{TemplateBinding ribbon:RibbonMenuButton.FocusedBorderBrush}" FocusedBackground="{TemplateBinding ribbon:RibbonMenuButton.FocusedBackground}" HorizontalContentAlignment="{TemplateBinding Control.HorizontalContentAlignment}" Padding="{TemplateBinding Control.Padding}" ClickMode="Press" Style="{x:Null}" FocusVisualStyle="{x:Null}" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropDownOpen, Mode=TwoWay}">
<rcp:RibbonToggleButton.Resources>
<Thickness Left="1" Top="1" Right="1" Bottom="2">
<ComponentResourceKey.Key TypeInTargetAssembly="{x:Type ribbon:Ribbon}" ResourceId="LargeImageMargin" />
</Thickness>
</rcp:RibbonToggleButton.Resources>
</rcp:RibbonToggleButton>
<Popup Name="PART_Popup" HorizontalOffset="1" VerticalOffset="-1" AllowsTransparency="True" Placement="Bottom" Focusable="False" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" IsOpen="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropDownOpen}">
<sdsc:SystemDropShadowChrome Name="Shadow" Color="Transparent" p15:KeyTipService.IsKeyTipScope="True" RenderOptions.ClearTypeHint="Enabled" xmlns:p15="clr-namespace:Microsoft.Windows.Controls;assembly=RibbonControlsLibrary,Version=4.0.0.11019,Culture=neutral,PublicKeyToken=31bf3856ad364e35">
<Border Name="MenuBorder" BorderThickness="{TemplateBinding Control.BorderThickness}" CornerRadius="2" BorderBrush="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Ribbon.BorderBrush}" Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Ribbon.Background}">
<Border Name="SubMenuInnerBorder" Background="{StaticResource ï}" BorderThickness="0" CornerRadius="2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollViewer Name="PART_SubMenuScrollViewer" Grid.Row="1" Margin="1" Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}">
<Grid RenderOptions.ClearTypeHint="Enabled">
<Canvas Name="BackgroundCanvas" Height="0" Width="0" HorizontalAlignment="Left" VerticalAlignment="Top">
<Rectangle Name="OpaqueRect" RadiusX="2" RadiusY="2" Height="{Binding ElementName=MenuBorder, Path=ActualHeight}" Width="{Binding ElementName=MenuBorder, Path=ActualWidth}" Fill="{Binding ElementName=MenuBorder, Path=Background}" />
<Rectangle Name="OverlayRect" RadiusX="2" RadiusY="2" Height="{Binding ElementName=SubMenuInnerBorder, Path=ActualHeight}" Width="{Binding ElementName=SubMenuInnerBorder, Path=ActualWidth}" Fill="{Binding ElementName=SubMenuInnerBorder, Path=Background}" />
</Canvas>
<ItemsPresenter Name="ItemsPresenter" KeyboardNavigation.TabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Cycle" Grid.IsSharedSizeScope="True" />
</Grid>
</ScrollViewer>
<Border Name="ResizeControl" Grid.Row="2" Visibility="Collapsed" Background="{StaticResource æ}" BorderThickness="0,1,0,0" BorderBrush="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Ribbon.BorderBrush}">
<Thumb Name="PART_ResizeThumb" Style="{StaticResource ç}" />
</Border>
</Grid>
</Border>
</Border>
</sdsc:SystemDropShadowChrome>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger SourceName="PART_SubMenuScrollViewer" Property="ScrollViewer.CanContentScroll" Value="False">
<Setter TargetName="OpaqueRect" Value="{Binding ElementName=PART_SubMenuScrollViewer, Path=VerticalOffset}" Property="Canvas.Top" />
<Setter TargetName="OpaqueRect" Value="{Binding ElementName=PART_SubMenuScrollViewer, Path=HorizontalOffset}" Property="Canvas.Left" />
<Setter TargetName="OverlayRect" Value="{Binding ElementName=PART_SubMenuScrollViewer, Path=VerticalOffset}" Property="Canvas.Top" />
<Setter TargetName="OverlayRect" Value="{Binding ElementName=PART_SubMenuScrollViewer, Path=HorizontalOffset}" Property="Canvas.Left" />
</Trigger>
<DataTrigger Value="True" Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsInQuickAccessToolBar}">
<Setter TargetName="PART_ToggleButton" Property="FrameworkElement.Height" Value="Auto" />
</DataTrigger>
<Trigger Property="UIElement.IsEnabled" Value="False">
<Setter TargetName="MainGrid" Value="{StaticResource Ë}" Property="TextElement.Foreground" />
</Trigger>
<Trigger Property="ribbon:RibbonMenuButton.HasGallery" Value="True">
<Setter TargetName="PART_SubMenuScrollViewer" Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
<Setter TargetName="PART_SubMenuScrollViewer" Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ribbon:RibbonMenuButton.CanUserResizeHorizontally" Value="True" />
<Condition Property="ribbon:RibbonMenuButton.CanUserResizeVertically" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="ResizeControl" Property="UIElement.Visibility" Value="Visible" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ribbon:RibbonMenuButton.CanUserResizeHorizontally" Value="False" />
<Condition Property="ribbon:RibbonMenuButton.CanUserResizeVertically" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="ResizeControl" Property="UIElement.Visibility" Value="Visible" />
<Setter TargetName="PART_ResizeThumb" Value="{StaticResource è}" Property="FrameworkElement.Style" />
</MultiTrigger>
<Trigger Property="ribbon:RibbonMenuButton.IsDropDownPositionedAbove" Value="True">
<Setter TargetName="ResizeControl" Property="Grid.Row" Value="0" />
<Setter TargetName="ResizeControl" Property="Border.BorderThickness" Value="0,0,0,1" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ribbon:RibbonMenuButton.IsDropDownPositionedAbove" Value="True" />
<Condition Property="ribbon:RibbonMenuButton.CanUserResizeHorizontally" Value="True" />
<Condition Property="ribbon:RibbonMenuButton.CanUserResizeVertically" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="PART_ResizeThumb" Value="{StaticResource é}" Property="FrameworkElement.Style" />
</MultiTrigger>
<Trigger Property="ItemsControl.HasItems" Value="False">
<Setter TargetName="PART_ToggleButton" Value="{x:Null}" Property="ribbon:RibbonTwoLineText.PathData" />
</Trigger>
<Trigger SourceName="PART_Popup" Property="Popup.HasDropShadow" Value="True">
<Setter TargetName="Shadow" Property="FrameworkElement.Margin" Value="0,0,5,5" />
<Setter TargetName="Shadow" Value="{StaticResource Õ}" Property="classic:SystemDropShadowChrome.Color" />
</Trigger>
<Trigger SourceName="PART_Popup" Property="Popup.IsOpen" Value="False">
<Setter TargetName="PART_Popup" Property="Popup.PopupAnimation" Value="None" />
</Trigger>
<DataTrigger Value="True" Binding="{Binding Path=HighContrast, Source={x:Static shell:SystemParameters2.Current}}">
<Setter TargetName="BackgroundCanvas" Property="UIElement.Visibility" Value="Collapsed" />
<Setter TargetName="Shadow" Property="classic:SystemDropShadowChrome.Color" Value="Transparent" />
<Setter TargetName="PART_Popup" Property="Popup.PopupAnimation" Value="None" />
<Setter TargetName="PART_SubMenuScrollViewer" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" Property="Control.Foreground" />
<Setter TargetName="MenuBorder" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" Property="Border.BorderBrush" />
<Setter TargetName="MenuBorder" Value="{DynamicResource {x:Static SystemColors.MenuBrushKey}}" Property="Border.Background" />
<Setter TargetName="MenuBorder" Property="Border.CornerRadius" Value="0" />
<Setter TargetName="ResizeControl" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" Property="Border.BorderBrush" />
<Setter TargetName="ResizeControl" Value="{DynamicResource {x:Static SystemColors.MenuBrushKey}}" Property="Border.Background" />
<Setter TargetName="SubMenuInnerBorder" Property="Border.Background" Value="#00FFFFFF" />
<Setter TargetName="SubMenuInnerBorder" Property="Border.CornerRadius" Value="0" />
<Setter TargetName="MainGrid" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" Property="TextElement.Foreground" />
</DataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled}" Value="False" />
<Condition Binding="{Binding Path=HighContrast, Source={x:Static shell:SystemParameters2.Current}}" Value="True" />
</MultiDataTrigger.Conditions>
<Setter TargetName="MainGrid" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" Property="TextElement.Foreground" />
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="ribbon:RibbonMenuButton.IsDropDownOpen" Value="True">
<Setter Property="ToolTipService.IsEnabled" Value="False" />
</Trigger>
</Style.Triggers>
</Style>
Anyway I suggest you to browse it by your own, in order to "discover" specific details that you may need to know for your project.
WPF 4.5
Can someone please take the below default style for ComboBox and show me how to change it so that I can set a BorderBrush color (or resource brush) via Style setter at the top "ComboBox" level...and then have that same color to flow all the way down to the BorderBrush property of the Border named "Border" within the ToggleButton template with key "ComboBoxToggleButton"?
THANKS!!!
<!--##########-->
<!--ComboBox-->
<!--##########-->
<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" Grid.ColumnSpan="2" CornerRadius="2,2,2,2" Background="{StaticResource FlowWhiteBrush}" BorderThickness="3,3,3,3" />
<Border Grid.Column="0" CornerRadius="2,0,0,2" Margin="3,3,3,3" Background="{StaticResource FlowWhiteBrush}" />
<Canvas x:Name="canDownArrow" Width="13" Height="13" HorizontalAlignment="Right" Margin="0,0,-19,0">
<Polygon Fill="{StaticResource FlowBlackBrush}">
<Polygon.Points>
<Point X="1" Y="1" />
<Point X="13" Y="1" />
<Point X="7" Y="13" />
</Polygon.Points>
</Polygon>
</Canvas>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Control.IsEnabled" Value="False">
<Setter TargetName="Border" Property="Opacity" Value="0.5"/>
<Setter TargetName="canDownArrow" Property="Opacity" Value="0.35"/>
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="Border" Property="Background" Value="{StaticResource FlowMediumGrayBrush}" />
<Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource FlowMediumGrayBrush}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="Background" Value="{StaticResource FlowMediumGrayBrush}" />
<Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource FlowMediumGrayBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">
<Border x:Name="PART_ContentHost" Padding="0,3,0,3" Focusable="False" Background="{TemplateBinding Background}" IsEnabled="{TemplateBinding IsEnabled}" />
</ControlTemplate>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderBrush" Value="Green" /><!-- GREEN DOES NOT MAKE IT DOWN TO ComboBoxToggleButton BorderBrush -->
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
<Setter Property="IsEditable" Value="False" />
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock FontSize="18" FontWeight="SemiBold" Text="{Binding}" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Grid>
<ToggleButton x:Name="ToggleButton" Template="{StaticResource ComboBoxToggleButton}" Grid.Column="2" FocusVisualStyle="{x:Null}" ClickMode="Press" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
<ContentPresenter x:Name="ContentSite" IsHitTestVisible="False" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Margin="6,4,36,5" VerticalAlignment="Center" HorizontalAlignment="Left"></ContentPresenter>
<TextBox x:Name="PART_EditableTextBox" TextBlock.FontSize="18" TextBlock.FontWeight="SemiBold" Template="{StaticResource ComboBoxTextBox}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="6,4,36,5" Focusable="True" Background="{TemplateBinding Background}" IsEnabled="{TemplateBinding IsEnabled}" IsReadOnly="{TemplateBinding IsReadOnly}" />
<Popup x:Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Slide">
<Grid x:Name="DropDown" SnapsToDevicePixels="True" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border x:Name="DropDownBorder" BorderThickness="3,3,3,3" BorderBrush="{StaticResource FlowMediumGrayBrush}" Background="{StaticResource FlowWhiteBrush}" />
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEditable" Value="False">
<Setter TargetName="PART_EditableTextBox" Property="IsEnabled" Value="False" />
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="PART_EditableTextBox" Property="Opacity" Value="0.5" />
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
</Trigger>
<Trigger SourceName="Popup" Property="AllowsTransparency" Value="true">
<Setter TargetName="DropDownBorder" Property="CornerRadius" Value="4" />
<Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border MinHeight="32" x:Name="Border" Padding="2,2,2,2" SnapsToDevicePixels="True" Background="Transparent">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected" />
<VisualState x:Name="SelectedUnfocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="Border" Property="Background" Value="{StaticResource FlowLightGrayBrush}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="Background" Value="{StaticResource FlowLightGrayBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Try this.I have added BorderBrush binding in Toggle button Template like this.
<Border x:Name="Border" BorderBrush="{Binding BorderBrush,RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Grid.ColumnSpan="2" CornerRadius="2,2,2,2" Background="{StaticResource FlowWhiteBrush}" BorderThickness="3,3,3,3" />
<Window.Resources>
<SolidColorBrush x:Key="FlowBlackBrush" Color="Black"></SolidColorBrush>
<SolidColorBrush x:Key="FlowWhiteBrush" Color="White"></SolidColorBrush>
<SolidColorBrush x:Key="FlowMediumGrayBrush" Color="DarkGray"></SolidColorBrush>
<SolidColorBrush x:Key="FlowLightGrayBrush" Color="LightGray"></SolidColorBrush>
<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<Border x:Name="Border" BorderBrush="{Binding BorderBrush,RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Grid.ColumnSpan="2" CornerRadius="2,2,2,2" Background="{StaticResource FlowWhiteBrush}" BorderThickness="3,3,3,3" />
<Border Grid.Column="0" CornerRadius="2,0,0,2" Margin="3,3,3,3" Background="{StaticResource FlowWhiteBrush}" />
<Canvas x:Name="canDownArrow" Width="13" Height="13" HorizontalAlignment="Right" Margin="0,0,-19,0">
<Polygon Fill="{StaticResource FlowBlackBrush}">
<Polygon.Points>
<Point X="1" Y="1" />
<Point X="13" Y="1" />
<Point X="7" Y="13" />
</Polygon.Points>
</Polygon>
</Canvas>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Control.IsEnabled" Value="False">
<Setter TargetName="Border" Property="Opacity" Value="0.5"/>
<Setter TargetName="canDownArrow" Property="Opacity" Value="0.35"/>
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="Border" Property="Background" Value="{StaticResource FlowMediumGrayBrush}" />
<Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource FlowMediumGrayBrush}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="Background" Value="{StaticResource FlowMediumGrayBrush}" />
<Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource FlowMediumGrayBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">
<Border x:Name="PART_ContentHost" Padding="0,3,0,3" Focusable="False" Background="{TemplateBinding Background}" IsEnabled="{TemplateBinding IsEnabled}" />
</ControlTemplate>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderBrush" Value="Green" />
<!-- GREEN DOES NOT MAKE IT DOWN TO ComboBoxToggleButton BorderBrush -->
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
<Setter Property="IsEditable" Value="False" />
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock FontSize="18" FontWeight="SemiBold" Text="{Binding}" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Grid>
<ToggleButton x:Name="ToggleButton" Template="{StaticResource ComboBoxToggleButton}" Grid.Column="2" FocusVisualStyle="{x:Null}" ClickMode="Press" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
<ContentPresenter x:Name="ContentSite" IsHitTestVisible="False" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Margin="6,4,36,5" VerticalAlignment="Center" HorizontalAlignment="Left"></ContentPresenter>
<TextBox x:Name="PART_EditableTextBox" TextBlock.FontSize="18" TextBlock.FontWeight="SemiBold" Template="{StaticResource ComboBoxTextBox}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="6,4,36,5" Focusable="True" Background="{TemplateBinding Background}" IsEnabled="{TemplateBinding IsEnabled}" IsReadOnly="{TemplateBinding IsReadOnly}" />
<Popup x:Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Slide">
<Grid x:Name="DropDown" SnapsToDevicePixels="True" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border x:Name="DropDownBorder" BorderThickness="3,3,3,3" BorderBrush="{StaticResource FlowMediumGrayBrush}" Background="{StaticResource FlowWhiteBrush}" />
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEditable" Value="False">
<Setter TargetName="PART_EditableTextBox" Property="IsEnabled" Value="False" />
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="PART_EditableTextBox" Property="Opacity" Value="0.5" />
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
</Trigger>
<Trigger SourceName="Popup" Property="AllowsTransparency" Value="true">
<Setter TargetName="DropDownBorder" Property="CornerRadius" Value="4" />
<Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border MinHeight="32" x:Name="Border" Padding="2,2,2,2" SnapsToDevicePixels="True" Background="Transparent">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected" />
<VisualState x:Name="SelectedUnfocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="Border" Property="Background" Value="{StaticResource FlowLightGrayBrush}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="Background" Value="{StaticResource FlowLightGrayBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<ComboBox Width="200" Height="30"></ComboBox>
RadMenuItem
RadMenuItem is used to present menu
<Style TargetType="{x:Type telerik:RadMenuItem}">
<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="{StaticResource ContextMenuBackground}"/>
<Setter Property="Foreground" Value="{StaticResource ContextMenuForeground}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type telerik:RadMenuItem}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition />
</Grid.RowDefinitions>
<Border x:Name="Border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding Background}"
BorderThickness="2"
CornerRadius="5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"
MinWidth="17"
SharedSizeGroup="Icon" />
<ColumnDefinition Width="Auto" MinWidth="5"
SharedSizeGroup="Name" />
<ColumnDefinition MinWidth="5" Width="Auto"
SharedSizeGroup="Shortcut" />
<ColumnDefinition MinWidth="10" Width="Auto"
SharedSizeGroup="Arrow" />
</Grid.ColumnDefinitions>
<ContentPresenter x:Name="Icon"
Margin="4,0,6,0"
VerticalAlignment="Center"
ContentSource="Icon" />
this piece of code is used to override the menuitem style and set foreground property
<ContentPresenter x:Name="HeaderHost"
Grid.Column="1"
Margin="{TemplateBinding Padding}"
ContentSource="Header"
RecognizesAccessKey="True" >
<ContentPresenter.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="TextTrimming" Value="CharacterEllipsis"/>
<Setter Property="FontSize" Value="11"/>
<Setter Property="FontFamily" Value="Arial Unicode MS"/>
<Style.Triggers>
<Trigger Property="controls:TextBlockService.IsTextTrimmed" Value="True">
<Setter Property="ToolTip" Value="{Binding Text, RelativeSource={RelativeSource Self}}"/>
</Trigger>
</Style.Triggers>
</Style>
</ContentPresenter.Resources>
</ContentPresenter>
<TextBlock x:Name="ShortCuts" Grid.Column="3" Margin="{TemplateBinding Padding}" >
</TextBlock>
<Popup x:Name="SubMenuPopup"
AllowsTransparency="true"
Focusable="false" Grid.IsSharedSizeScope="True"
IsOpen="{Binding Path=IsSubmenuOpen,
RelativeSource={RelativeSource TemplatedParent}}"
Placement="Right"
PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}"
VerticalOffset="-3">
<Grid x:Name="SubMenu">
<Border x:Name="SubMenuBorder"
Background="{TemplateBinding Background}"
BorderBrush="Gray"
BorderThickness="1"
CornerRadius="5">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
</Border>
</Grid>
</Popup>
</Grid>
</Border>
this separator property is set, because of this property i am getting on extra row in the Rad Menu Item
<Rectangle x:Name="Separator" Grid.Row="1"
Height="1" Visibility="Collapsed"
Fill="{DynamicResource GridView_GridLinesItemVertical}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="attachedBehaviors:MenuItemHasSeparatorBehavior.HasSeparator" Value="True">
<Setter TargetName="Separator" Property="Visibility" Value="Visible"/>
</Trigger>
<Trigger Property="Role" Value="TopLevelHeader">
<Setter Property="Margin" Value="2" />
<Setter Property="Padding" Value="6,3,6,3" />
<Setter TargetName="SubMenuPopup" Property="Placement" Value="Bottom" />
</Trigger>
<Trigger Property="Role" Value="TopLevelItem">
<Setter Property="Margin" Value="2" />
<Setter Property="Padding" Value="6,3,6,3" />
</Trigger>
<Trigger Property="Role" Value="SubmenuHeader">
<Setter Property="DockPanel.Dock" Value="Top" />
<Setter Property="Padding" Value="0,2,0,2" />
</Trigger>
<Trigger Property="Role" Value="SubmenuItem">
<Setter Property="DockPanel.Dock" Value="Top" />
<Setter Property="Padding" Value="0,2,0,2" />
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger SourceName="SubMenuPopup" Property="AllowsTransparency" Value="true">
<Setter TargetName="SubMenu" Property="Margin" Value="2" />
<Setter TargetName="SubMenu" Property="SnapsToDevicePixels" Value="true" />
<Setter TargetName="SubMenuBorder" Property="BitmapEffect" Value="{DynamicResource PopupDropShadow}" />
</Trigger>
<Trigger Property="IsHighlighted" Value="true">
<Setter TargetName="Border" Property="Background" Value="{StaticResource BR_Menu_Highlight}" />
<Setter Property="Foreground" Value="{StaticResource BR_SE_White}" />
<Setter TargetName="ShortCuts" Property="Foreground" Value="{StaticResource BR_SE_White}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
<Setter TargetName="ShortCuts" Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
RadContextMenu
<Style TargetType="{x:Type telerik:RadContextMenu}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Background" Value="{StaticResource ContextMenuBackground}"/>
<Setter Property="FontSize" Value="11"/>
<Setter Property="FontFamily" Value="Arial Unicode MS"/>
<Setter Property="Grid.IsSharedSizeScope" Value="True"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type telerik:RadContextMenu}">
<Border x:Name="Border"
Background="{TemplateBinding Background}"
BorderBrush="{StaticResource ContextMenuBorderBrush}"
BorderThickness="1"
CornerRadius="5">
<StackPanel ClipToBounds="True"
IsItemsHost="True"
Orientation="Vertical" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
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>