Stretch ListBoxItem Style Problems - wpf

I have a problem stretching the content of a ListBoxItem. I use a DataTemplate with a Grid to place the content of the last column aligned at the right. But I must have something in the basic style of the controls that prevents this kind of display - the "*" ("consume all the rest of space") displays like "auto" ("take only what you really need").
Style of all ListBoxes:
<Style TargetType="{x:Type ListBox}">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource SolidBorderBrush}" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBox}">
<Grid HorizontalAlignment="Stretch">
<Border x:Name="Border" HorizontalAlignment="Stretch"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" />
<ScrollViewer Margin="1" Style="{DynamicResource NuclearScrollViewer}"
Focusable="false" Background="{DynamicResource LightBrush}"
x:Name="scrollViewer">
<StackPanel Margin="2" IsItemsHost="true" HorizontalAlignment="Stretch" />
</ScrollViewer>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background"
Value="{DynamicResource DisabledBackgroundBrush}"
TargetName="Border" />
<Setter Property="BorderBrush"
Value="{DynamicResource DisabledBorderBrush}"
TargetName="Border" />
<Setter Property="Background"
TargetName="scrollViewer"
Value="{DynamicResource DisabledBackgroundBrush}"/>
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style d:IsControlPart="True" TargetType="{x:Type ListBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid SnapsToDevicePixels="true" HorizontalAlignment="Stretch" >
<Border HorizontalAlignment="Stretch" x:Name="Border" Opacity="0.25"
Margin="0,1,0,1" Background="{DynamicResource NormalBrush}"
BorderBrush="{DynamicResource NormalBorderBrush}"
BorderThickness="1,1,1,1" CornerRadius="0,0,0,0" Padding="0,0,0,0" />
<Rectangle Opacity="0.25" Fill="{DynamicResource LightBrush}" Stroke="{x:Null}"
Height="10.849" Margin="1.153,1.151,1,0" VerticalAlignment="Top" />
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Margin="5,2,0,2" x:Name="contentPresenter" />
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Selector.IsSelected" Value="True"/>
<Condition Property="IsEnabled" Value="False"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="Border"
Value="{DynamicResource DisabledBackgroundBrush}"/>
<Setter Property="BorderBrush" TargetName="Border"
Value="{DynamicResource DisabledBorderBrush}"/>
</MultiTrigger>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Opacity" TargetName="Border" Value="1" />
<Setter Property="Background" TargetName="Border"
Value="{DynamicResource SelectedBackgroundBrush}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="Selector.IsSelected" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="Border"
Value="{DynamicResource MouseOverBrush}" />
<Setter Property="Opacity" TargetName="Border" Value="1" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Selector.IsSelected" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Opacity" TargetName="Border" Value="0.65" />
<Setter Property="Background" TargetName="Border"
Value="{DynamicResource SelectedBackgroundBrush}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="true" />
<Condition Property="Selector.IsSelectionActive" Value="false" />
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="Border"
Value="{DynamicResource SelectedBackgroundBrush}" />
<Setter Property="Opacity" TargetName="Border" Value="0.6" />
</MultiTrigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground"
Value="{DynamicResource DisabledForegroundBrush}" />
<Setter Property="Background" TargetName="Border"
Value="{DynamicResource DisabledBackgroundBrush}"/>
<Setter Property="BorderBrush" TargetName="Border"
Value="{DynamicResource DisabledBorderBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
My ListBox:
<ListBox Height="220"
DataContext="{Binding}"
ItemsSource="{Binding Persons}"
SelectedItem="{Binding SelectedPerson}"
VirtualizingStackPanel.VirtualizationMode="Recycling"
VirtualizingStackPanel.IsVirtualizing="True"
ScrollViewer.IsDeferredScrollingEnabled="True"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="True">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Stretch"
MaxWidth="{Binding RelativeSource={RelativeSource
Mode=FindAncestor,
AncestorType={x:Type ListBox}},
Path=ActualWidth}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Grid.RowSpan="2"
Width="25" Height="25"
Margin="0,0,5,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Text="{Binding Path=BusinessDataObject.Category}">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Transparent"/>
<Style.Triggers>
<Trigger Property="Text" Value="A">
<Setter Property="Background" Value="Red"/>
</Trigger>
<Trigger Property="Text" Value="B">
<Setter Property="Background" Value="Orange"/>
</Trigger>
<Trigger Property="Text" Value="C">
<Setter Property="Background" Value="Blue"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<TextBlock Grid.Row="0"
Grid.Column="1"
Margin="0,0,10,0"
HorizontalAlignment="Left"
TextWrapping="Wrap"
FontWeight="Bold"
Text="{Binding Path=BusinessDataObject.FullNameReversed}"/>
<TextBlock Grid.Row="1" Grid.Column="1" Margin="0,0,10,0"
HorizontalAlignment="Left"
Text="{Binding Path=BusinessDataObject.Position}"/>
<TextBlock Grid.Row="0" Grid.Column="2" Margin="0,0,0,0"
HorizontalAlignment="Right"
TextAlignment="Left"
Text="{Binding Path=BusinessDataObject.Phone}"/>
<TextBlock Grid.Row="1" Grid.Column="2" Margin="0,0,0,0"
HorizontalAlignment="Right"
TextAlignment="Left"
Text="{Binding Path=BusinessDataObject.Mobile}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Category should be left, Phone & Mobile should be on the right and Name & Position should fill the whole space that is left. It seems to be that there is no "whole" space within the Items although they optically fill the space of the listboxes width.
Could anyone help me? I'm getting mad about this. :-(
Edit: Picture

Try setting the HorizontalContentAlignment for the ListBoxItem to Stretch. Something like the one in this link except using "ListBox" and "ListBoxItem":

Related

RibbonMenuButton Style and template

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.

Change parent properties through trigger

I have the following XAML for a ComboBox custom design
<ControlTemplate TargetType="{x:Type ToggleButton}" x:Key="ComboBoxToggleButtonTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="32" />
</Grid.ColumnDefinitions>
<Border BorderBrush="{StaticResource CleoComboBoxBorderBrush}" BorderThickness="1,1,1,1" x:Name="Border" Background="{StaticResource CleoComboBoxBackgroundBrush}" Grid.ColumnSpan="2" />
<Border x:Name="Border2" Margin="1,1,1,1" BorderBrush="{StaticResource CleoComboBoxBorderBrush}" BorderThickness="0,0,0,0" Background="{StaticResource CleoComboBoxBackgroundBrush}" Grid.Column="0" />
<Path Margin="0,0,3,0" Data="M0,0 L4,4 8,0z" HorizontalAlignment="Center" Fill="{StaticResource CleoComboBoxToggleButtonBrush}" x:Name="Arrow" VerticalAlignment="Center" Width="8" Grid.Column="1" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" TargetName="Border" Value="{StaticResource CleoComboBoxBorderSelectedBrush}" />
<Setter Property="BorderThickness" TargetName="Border" Value="2" />
<Setter Property="Shape.Fill" TargetName="Arrow" Value="{StaticResource CleoComboBoxBorderSelectedBrush}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" TargetName="Border" Value="{StaticResource CleoComboBoxBorderHoverBrush}" />
<Setter Property="BorderThickness" TargetName="Border" Value="2" />
<Setter Property="BorderBrush" TargetName="Border2" Value="{StaticResource CleoComboBoxBorderHoverBrush}" />
<Setter Property="BorderThickness" TargetName="Border2" Value="1,1,0,1" />
<Setter Property="Shape.Fill" TargetName="Arrow" Value="{StaticResource CleoComboBoxBorderHoverBrush}" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="BorderBrush" TargetName="Border" Value="{StaticResource CleoComboBoxBorderSelectedBrush}" />
<Setter Property="BorderThickness" TargetName="Border" Value="2" />
<Setter Property="BorderBrush" TargetName="Border2" Value="{StaticResource CleoComboBoxBorderSelectedBrush}" />
<Setter Property="BorderThickness" TargetName="Border2" Value="1,1,0,1" />
<Setter Property="Shape.Fill" TargetName="Arrow" Value="{StaticResource CleoComboBoxBorderSelectedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="Border" Value="#FFEEEEEE" />
<Setter Property="BorderBrush" TargetName="Border" Value="#FFAAAAAA" />
<Setter Property="Background" TargetName="Border2" Value="#FFEEEEEE" />
<Setter Property="BorderBrush" TargetName="Border2" Value="#FFAAAAAA" />
<Setter Property="Foreground" Value="#FF888888" />
<Setter Property="Shape.Fill" TargetName="Arrow" Value="#66ADADAD" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate TargetType="{x:Type TextBox}" x:Key="ComboBoxTextBoxTemplate">
<Border x:Name="PART_ContentHost" Background="{StaticResource CleoComboBoxBackgroundBrush}" Focusable="False" />
</ControlTemplate>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Foreground" Value="{StaticResource CleoComboBoxTextBrush}" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border x:Name="Border" SnapsToDevicePixels="True" Padding="4,4,4,4" BorderBrush="Transparent" BorderThickness="1,1,1,1">
<ContentControl ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="True">
<Setter Property="Background" TargetName="Border" Value="{StaticResource CleoComboBoxHighlightedItemBackgroundBrush}"/>
<Setter Property="BorderBrush" TargetName="Border" Value="{StaticResource CleoComboBoxHighlightedItemBorderBrush}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="#FF888888"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type 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="TextElement.Foreground" Value="{StaticResource CleoComboBoxTextBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Grid x:Name="Grid">
<ToggleButton ClickMode="Press" x:Name="ToggleButton" IsChecked="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
Focusable="False" Grid.Column="2" Template="{StaticResource ComboBoxToggleButtonTemplate}" />
<ContentPresenter Margin="3,3,23,3" HorizontalAlignment="Left" x:Name="ContentSite" VerticalAlignment="Center"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" Content="{TemplateBinding SelectionBoxItem}" IsHitTestVisible="False" />
<TextBox Margin="3,3,23,3" Visibility="Hidden" HorizontalAlignment="Left" x:Name="PART_EditableTextBox" Background="Transparent"
VerticalAlignment="Center" Style="{x:Null}" IsReadOnly="False" Focusable="True" xml:space="preserve" Template="{StaticResource ComboBoxTextBoxTemplate}" />
<Popup Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" IsOpen="{TemplateBinding IsDropDownOpen}" PopupAnimation="Fade">
<Grid MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding ComboBox.MaxDropDownHeight}" x:Name="DropDown" SnapsToDevicePixels="True">
<Border BorderBrush="{StaticResource CleoComboBoxBorderBrush}" BorderThickness="1,1,1,1" x:Name="DropDownBorder" Background="{StaticResource CleoComboBoxBackgroundBrush}" />
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasItems" Value="False">
<Setter Property="MinHeight" TargetName="DropDownBorder" Value="95" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="#FF888888" />
</Trigger>
<Trigger Property="IsGrouping" Value="True">
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
</Trigger>
<Trigger Property="Window.AllowsTransparency" SourceName="Popup" Value="True">
<Setter Property="Margin" TargetName="DropDownBorder" Value="0,2,0,0" />
</Trigger>
<Trigger Property="IsEditable" Value="True">
<Setter Property="KeyboardNavigation.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>
In the ComboBoxToggleButtonTemplate I have added a Trigger for the IsFocussed property where the value is true and want to change the border color and thickness (amongst other things)
I have tried this trigger in the ComboBox style as well but I cannot seem to get this to work at all, and really hitting a brick wall as to what the issue may be, can anyone shed any light on this please?
A combo box toggle button never gets the focus, so using that as a trigger wouldn't work. The focus always stays with the edit / static text or the item list in the drop down.
The Condition has to look something like this
<Condition Binding="{Binding IsFocussed, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ComboBox}}}" Value="true"/>
when templating from within the Toggle Button.

WPF combobox default hover color on togglebutton

I have a combobox and it's like a simple bar without the arrow. Almost possible to make all sort of color changes except that I can't figure out how to change the default blue color when hovering on the combobox itself. Your help is greatly appreciated.
What's annoying also is the portion in the styling that seems to be where my answer lies, but even commenting it all out did not cause any issue in building the comboBox, so I wonder if I have to override something to make this happen. It's the portion that is termed "ComboBoxTextBoxTemplate"
<Style TargetType="{x:Type ComboBox}">
<Setter Property="Foreground" Value="White" />
<Setter Property="BorderBrush" Value="White" />
<Setter Property="Background" Value="White" />
<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="FontFamily" Value="Resources/#AGENCYR" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Cursor" Value="Arrow"/>
<Setter Property="Height" Value="34"/>
<Setter Property="Width" Value="387"/>
<Setter Property="MinWidth" Value="50"/>
<Setter Property="MinHeight" Value="32"/>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<ToggleButton ClickMode="Press" Name="ToggleButton" Grid.Column="2" Focusable="False"
IsChecked="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
Template="{StaticResource ComboBoxToggleButtonTemplate}"/>
<ContentPresenter
Margin="3,3,23,3"
HorizontalAlignment="Left"
Name="ContentSite"
VerticalAlignment="Center"
ContentTemplate="{TemplateBinding ComboBox.SelectionBoxItemTemplate}"
Content="{TemplateBinding ComboBox.SelectionBoxItem}"
IsHitTestVisible="False" />
<TextBox
Margin="3,3,23,3"
Visibility="Hidden"
HorizontalAlignment="Left"
Name="PART_EditableTextBox"
Background="Transparent"
VerticalAlignment="Center"
Style="{x:Null}"
IsReadOnly="False"
Focusable="True"
xml:space="preserve"
Template="{StaticResource ComboBoxTextBoxTemplate}"/>
<Popup
Placement="Bottom"
Name="Popup"
Focusable="False"
AllowsTransparency="True"
IsOpen="{TemplateBinding ComboBox.IsDropDownOpen}"
PopupAnimation="Fade">
<Grid
MinWidth="{TemplateBinding FrameworkElement.ActualWidth}"
MaxHeight="{TemplateBinding ComboBox.MaxDropDownHeight}"
Name="DropDown"
SnapsToDevicePixels="True">
<Border
BorderBrush="{StaticResource NormalBorderBrush}"
BorderThickness="1,1,1,1"
Name="DropDownBorder"
Background="{StaticResource WindowBackgroundBrush}"/>
<ScrollViewer
Margin="4,6,4,6"
SnapsToDevicePixels="True">
<ItemsPresenter
KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter Property="Panel.Background" Value="Red"/>
</Trigger>
<Trigger Property="ItemsControl.HasItems" Value="False">
<Setter Property="FrameworkElement.MinHeight" TargetName="DropDownBorder" Value="95"/>
</Trigger>
<Trigger Property="UIElement.IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
</Trigger>
<Trigger Property="ItemsControl.IsGrouping" Value="True">
<Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
</Trigger>
<Trigger Property="Window.AllowsTransparency" SourceName="Popup" Value="True">
<Setter Property="Border.CornerRadius" TargetName="DropDownBorder" Value="4"/>
<Setter Property="FrameworkElement.Margin" TargetName="DropDownBorder" Value="0,2,0,0"/>
</Trigger>
<Trigger Property="ComboBox.IsEditable" Value="True">
<Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
<Setter Property="UIElement.Visibility" TargetName="PART_EditableTextBox" Value="Visible"/>
<Setter Property="UIElement.Visibility" TargetName="ContentSite" Value="Hidden"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<ToggleButton
Name="ToggleButton"
BorderBrush="Gray"
BorderThickness="0"
Background="Gray"
Grid.Column="2"
Focusable="false"
IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
ClickMode="Release">
</ToggleButton>
<ContentPresenter
Name="ContentSite"
IsHitTestVisible="False"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
Margin="10,3,30,3"
VerticalAlignment="Center"
HorizontalAlignment="Center" />
<Popup
Name="Popup"
Placement="Bottom"
IsOpen="{TemplateBinding IsDropDownOpen}"
AllowsTransparency="True"
Focusable="False"
PopupAnimation="Fade">
<Grid
Name="DropDown"
SnapsToDevicePixels="True"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border
x:Name="DropDownBorder"
Background="White"
BorderThickness="1"
BorderBrush="Black"/>
<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="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</Trigger>
<Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
<Setter TargetName="DropDownBorder" Property="CornerRadius" Value="0"/>
<Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,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>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Foreground" Value="Black" />
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border
Name="Border"
SnapsToDevicePixels="True"
Padding="2,2,2,2">
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="ComboBoxItem.IsHighlighted" Value="True">
<Setter Property="Panel.Background" TargetName="Border" Value="{StaticResource CustomBrush1}"/>
</Trigger>
<Trigger Property="UIElement.IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"/>
</Style.Resources>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True" >
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#24afb2" />
</Trigger>
<Trigger Property="IsSelected" Value="True" >
<Setter Property="Background" Value="#24afb2" />
<Setter Property="Foreground" Value="White" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsFocused" Value="True"/>
<Condition Property="IsMouseOver" Value="False"/>
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#24afb2" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True"/>
<Condition Property="IsMouseOver" Value="False"/>
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="Black" />
</MultiTrigger>
</Style.Triggers>
</Style>
<ControlTemplate TargetType="TextBox" x:Key="ComboBoxTextBoxTemplate">
<Border
Name="PART_ContentHost"
Background="Gray"
Focusable="False" />
</ControlTemplate>
<ControlTemplate TargetType="ToggleButton" x:Key="ComboBoxToggleButtonTemplate">
<!--<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="16" />
</Grid.ColumnDefinitions>
<Border
BorderBrush="Black"
CornerRadius="2,2,2,2"
BorderThickness="1,1,1,1"
Name="Border"
Background="WhiteSmoke"
Grid.ColumnSpan="2" />
<Border
Margin="1,1,1,1"
BorderBrush="{StaticResource NormalBorderBrush}"
CornerRadius="2,0,0,2"
BorderThickness="0,0,1,0"
Background="AliceBlue"
Grid.Column="0" />
<Path
Margin="0,0,3,0"
Data="M0,0L4,4 8,0z"
HorizontalAlignment="Center"
Fill="{StaticResource GlyphBrush}"
Name="Arrow"
VerticalAlignment="Center"
Width="8"
Grid.Column="1" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter Property="Panel.Background" TargetName="Border" Value="WhiteSmoke"/>
</Trigger>
<Trigger Property="ToggleButton.IsChecked" Value="True">
<Setter Property="Panel.Background" TargetName="Border" Value="WhiteSmoke"/>
<Setter Property="Shape.Fill" TargetName="Arrow" Value="#FF8D979E"/>
</Trigger>
<Trigger Property="UIElement.IsEnabled" Value="False">
<Setter Property="Panel.Background" TargetName="Border" Value="{StaticResource DisabledBackgroundBrush}"/>
<Setter Property="Border.BorderBrush" TargetName="Border" Value="{StaticResource DisabledBorderBrush}"/>
<Setter Property="TextElement.Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
<Setter Property="Shape.Fill" TargetName="Arrow" Value="#66FFFFFF"/>
</Trigger>
</ControlTemplate.Triggers>-->
</ControlTemplate>
<!-- The Actual ComboBox -->
<Grid>
<ComboBox x:Name="cmbNames" ItemsSource="{Binding SelectedName}" DisplayMemberPath ="FirstName" Width="454">
</ComboBox>
<TextBlock x:Name="txtComboBox" Style="{StaticResource ComboTextBox}"
Visibility="{Binding SelectedItem, ElementName=cmbNames, Converter={StaticResource NullToVisibilityConverter}}"
Text=" Select ..." />
</Grid>
I've done my best to figure out what you're trying to accomplish here, and I made some tweaks that should at least get you to a reasonable starting point. I had to improve with the colors since you left out some of the brush resources you were referencing ;).
<SolidColorBrush x:Key="CustomBrush1"
Color="Magenta" />
<SolidColorBrush x:Key="DisabledForegroundBrush"
Color="Gray" />
<SolidColorBrush x:Key="DisabledBackgroundBrush"
Color="Gray" />
<SolidColorBrush x:Key="DisabledBorderBrush"
Color="Gray" />
<SolidColorBrush x:Key="NormalBorderBrush"
Color="Black" />
<DrawingBrush x:Key="GlyphBrush">
<DrawingBrush.Drawing>
<GeometryDrawing Brush="Black"
Geometry="M 0,0 L 4,4 L 8,0 Z" />
</DrawingBrush.Drawing>
</DrawingBrush>
<ControlTemplate TargetType="TextBox"
x:Key="ComboBoxTextBoxTemplate">
<Border Name="PART_ContentHost"
Background="Gray"
Focusable="False" />
</ControlTemplate>
<ControlTemplate TargetType="ToggleButton"
x:Key="ComboBoxToggleButtonTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="16" />
</Grid.ColumnDefinitions>
<Border BorderBrush="Black"
CornerRadius="2,2,2,2"
BorderThickness="1,1,1,1"
Name="Border"
Background="WhiteSmoke"
Grid.ColumnSpan="2" />
<Path Margin="0,0,3,0"
Data="M0,0L4,4 8,0z"
HorizontalAlignment="Center"
Fill="{StaticResource GlyphBrush}"
Name="Arrow"
VerticalAlignment="Center"
Width="8"
Grid.Column="1" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver"
Value="True">
<Setter Property="Panel.Background"
TargetName="Border"
Value="DodgerBlue" />
</Trigger>
<Trigger Property="ToggleButton.IsChecked"
Value="True">
<Setter Property="Panel.Background"
TargetName="Border"
Value="WhiteSmoke" />
<Setter Property="Shape.Fill"
TargetName="Arrow"
Value="#FF8D979E" />
</Trigger>
<Trigger Property="UIElement.IsEnabled"
Value="False">
<Setter Property="Panel.Background"
TargetName="Border"
Value="{StaticResource DisabledBackgroundBrush}" />
<Setter Property="Border.BorderBrush"
TargetName="Border"
Value="{StaticResource DisabledBorderBrush}" />
<Setter Property="TextElement.Foreground"
Value="{StaticResource DisabledForegroundBrush}" />
<Setter Property="Shape.Fill"
TargetName="Arrow"
Value="#66FFFFFF" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="Foreground"
Value="Black" />
<Setter Property="BorderBrush"
Value="White" />
<Setter Property="Background"
Value="White" />
<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="FontFamily"
Value="Resources/#AGENCYR" />
<Setter Property="FontSize"
Value="16" />
<Setter Property="FontWeight"
Value="Normal" />
<Setter Property="HorizontalAlignment"
Value="Left" />
<Setter Property="VerticalAlignment"
Value="Top" />
<Setter Property="Cursor"
Value="Arrow" />
<Setter Property="Height"
Value="34" />
<Setter Property="Width"
Value="387" />
<Setter Property="MinWidth"
Value="50" />
<Setter Property="MinHeight"
Value="32" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<ToggleButton Name="ToggleButton"
BorderBrush="Gray"
BorderThickness="0"
Background="Gray"
Grid.Column="2"
Focusable="false"
IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
ClickMode="Release"
Template="{StaticResource ComboBoxToggleButtonTemplate}" />
<ContentPresenter Name="ContentSite"
IsHitTestVisible="False"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
Margin="10,3,30,3"
VerticalAlignment="Center"
HorizontalAlignment="Center" />
<Popup Name="Popup"
Placement="Bottom"
IsOpen="{TemplateBinding IsDropDownOpen}"
AllowsTransparency="True"
Focusable="False"
PopupAnimation="Fade">
<Grid Name="DropDown"
SnapsToDevicePixels="True"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border x:Name="DropDownBorder"
Background="White"
BorderThickness="1"
BorderBrush="Black" />
<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="IsGrouping"
Value="true">
<Setter Property="ScrollViewer.CanContentScroll"
Value="false" />
</Trigger>
<Trigger SourceName="Popup"
Property="Popup.AllowsTransparency"
Value="true">
<Setter TargetName="DropDownBorder"
Property="CornerRadius"
Value="0" />
<Setter TargetName="DropDownBorder"
Property="Margin"
Value="0,2,0,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>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Foreground"
Value="Black" />
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border Name="Border"
SnapsToDevicePixels="True"
Padding="2,2,2,2">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="ComboBoxItem.IsHighlighted"
Value="True">
<Setter Property="Panel.Background"
TargetName="Border"
Value="{StaticResource CustomBrush1}" />
</Trigger>
<Trigger Property="UIElement.IsEnabled"
Value="False">
<Setter Property="TextElement.Foreground"
Value="{StaticResource DisabledForegroundBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" />
</Style.Resources>
<Style.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Foreground"
Value="White" />
<Setter Property="Background"
Value="#24afb2" />
</Trigger>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Background"
Value="#24afb2" />
<Setter Property="Foreground"
Value="White" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsFocused"
Value="True" />
<Condition Property="IsMouseOver"
Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Foreground"
Value="White" />
<Setter Property="Background"
Value="#24afb2" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected"
Value="True" />
<Condition Property="IsMouseOver"
Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Foreground"
Value="Black" />
</MultiTrigger>
</Style.Triggers>
</Style>
The style doesn't define a template for editable ComboBox instances, which I think may have been what your other template was trying to do. Perhaps you can extract it to a separate template, which you can set via a Style setter when IsEditable is True.
Mike, I took your template and embedded it with mine using the textbox, however I got the arrow back in the comboBox which I really wanted to avoid. But the good thing was that I removed the textbox from inside the combobox template and was able to remove that another template.... (it's all shown as commented)
<Style x:Key="ComboTextBox" TargetType="{x:Type TextBlock}">
<Setter Property="IsHitTestVisible" Value="False" />
<Setter Property="FontFamily" Value="Resources/#AGENCYR" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center" />
<!--<Setter Property="Foreground" Value="#FFA2C3C4" />-->
<!--<Setter Property="Foreground" Value="#FF3CEFF4" />-->
<Setter Property="Foreground" Value="White" />
<!--<Setter Property="Background" Value="Yellow" />-->
</Style>
<ControlTemplate TargetType="TextBox"
x:Key="ComboBoxTextBoxTemplate">
<Border Name="PART_ContentHost"
Background="Gray"
Focusable="False" />
</ControlTemplate>
<ControlTemplate TargetType="ToggleButton"
x:Key="ComboBoxToggleButtonTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="16" />
</Grid.ColumnDefinitions>
<Border BorderBrush="Gray"
CornerRadius="2,2,2,2"
BorderThickness="0,0,0,0"
Name="Border"
Background="Gray"
Grid.ColumnSpan="2" />
<Path Margin="0,0,3,0"
Data="M0,0L4,4 8,0z"
HorizontalAlignment="Center"
Fill="{StaticResource GlyphBrush}"
Name="Arrow"
VerticalAlignment="Center"
Width="8"
Grid.Column="1" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver"
Value="True">
<Setter Property="Panel.Background"
TargetName="Border"
Value="Gray" />
</Trigger>
<Trigger Property="ToggleButton.IsChecked"
Value="True">
<Setter Property="Panel.Background"
TargetName="Border"
Value="Gray" />
<Setter Property="Shape.Fill"
TargetName="Arrow"
Value="#FF8D979E" />
</Trigger>
<Trigger Property="UIElement.IsEnabled"
Value="False">
<Setter Property="Panel.Background"
TargetName="Border"
Value="{StaticResource DisabledBackgroundBrush}" />
<Setter Property="Border.BorderBrush"
TargetName="Border"
Value="{StaticResource DisabledBorderBrush}" />
<Setter Property="TextElement.Foreground"
Value="{StaticResource DisabledForegroundBrush}" />
<Setter Property="Shape.Fill"
TargetName="Arrow"
Value="#66FFFFFF" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="Foreground"
Value="#FF3CEFF4" />
<Setter Property="BorderBrush"
Value="White" />
<Setter Property="Background"
Value="White" />
<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="FontFamily"
Value="Resources/#AGENCYR" />
<Setter Property="FontSize"
Value="16" />
<Setter Property="FontWeight"
Value="Normal" />
<Setter Property="HorizontalAlignment"
Value="Left" />
<Setter Property="VerticalAlignment"
Value="Top" />
<Setter Property="Cursor"
Value="Arrow" />
<Setter Property="Height"
Value="34" />
<Setter Property="Width"
Value="387" />
<Setter Property="MinWidth"
Value="50" />
<Setter Property="MinHeight"
Value="32" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<ToggleButton Name="ToggleButton"
BorderBrush="Gray"
BorderThickness="0"
Background="Gray"
Grid.Column="2"
Focusable="false"
IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
ClickMode="Release"
Template="{StaticResource ComboBoxToggleButtonTemplate}" />
<ContentPresenter Name="ContentSite"
IsHitTestVisible="False"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
Margin="10,3,30,3"
VerticalAlignment="Center"
HorizontalAlignment="Left" />
<!-- REMOVED THIS ONE TOO <TextBox
Margin="3,3,23,3"
Visibility="Hidden"
HorizontalAlignment="Left"
Name="PART_EditableTextBox"
Background="Transparent"
VerticalAlignment="Left"
Style="{x:Null}"
IsReadOnly="False"
Focusable="True"
xml:space="preserve"
Template="{StaticResource ComboBoxTextBoxTemplate}"/>-->
<Popup Name="Popup"
Placement="Bottom"
IsOpen="{TemplateBinding IsDropDownOpen}"
AllowsTransparency="True"
Focusable="False"
PopupAnimation="Fade">
<Grid Name="DropDown"
SnapsToDevicePixels="True"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border Name="DropDownBorder"
Background="White"
BorderThickness="1"
BorderBrush="Black" />
<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="IsGrouping"
Value="true">
<Setter Property="ScrollViewer.CanContentScroll"
Value="false" />
</Trigger>
<Trigger SourceName="Popup"
Property="Popup.AllowsTransparency"
Value="true">
<Setter TargetName="DropDownBorder"
Property="CornerRadius"
Value="0" />
<Setter TargetName="DropDownBorder"
Property="Margin"
Value="0,2,0,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>
<!-- FINALLY REMOVED THIS ONE <Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<ToggleButton
Name="ToggleButton"
BorderBrush="Gray"
BorderThickness="0"
Background="Gray"
Grid.Column="2"
Focusable="false"
IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
ClickMode="Release">
</ToggleButton>
<ContentPresenter
Name="ContentSite"
IsHitTestVisible="False"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
Margin="10,3,30,3"
VerticalAlignment="Center"
HorizontalAlignment="Left" />
<Popup
Name="Popup"
Placement="Bottom"
IsOpen="{TemplateBinding IsDropDownOpen}"
AllowsTransparency="True"
Focusable="False"
PopupAnimation="Fade">
<Grid
Name="DropDown"
SnapsToDevicePixels="True"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border
x:Name="DropDownBorder"
Background="White"
BorderThickness="1"
BorderBrush="Black"/>
<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="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</Trigger>
<Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
<Setter TargetName="DropDownBorder" Property="CornerRadius" Value="0"/>
<Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,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>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Foreground"
Value="Black" />
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border Name="Border"
SnapsToDevicePixels="True"
Padding="2,2,2,2">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="ComboBoxItem.IsHighlighted"
Value="True">
<Setter Property="Panel.Background"
TargetName="Border"
Value="{StaticResource CustomBrush1}" />
</Trigger>
<Trigger Property="UIElement.IsEnabled"
Value="False">
<Setter Property="TextElement.Foreground"
Value="{StaticResource DisabledForegroundBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" />
</Style.Resources>
<Style.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Foreground"
Value="White" />
<Setter Property="Background"
Value="#24afb2" />
</Trigger>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Background"
Value="#24afb2" />
<Setter Property="Foreground"
Value="White" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsFocused"
Value="True" />
<Condition Property="IsMouseOver"
Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Foreground"
Value="White" />
<Setter Property="Background"
Value="#24afb2" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected"
Value="True" />
<Condition Property="IsMouseOver"
Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Foreground"
Value="Black" />
</MultiTrigger>
</Style.Triggers>
</Style>
This now works by setting the ToogleButton in ControlTemplate for both the trigger as:
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter Property="Panel.Background" TargetName="Border" Value="Gray" />
</Trigger>
<Trigger Property="ToggleButton.IsChecked" Value="True">
<Setter Property="Panel.Background" TargetName="Border" Value="Gray" />
</Trigger>
And the combobox being used:
<!-- The Actual ComboBox -->
<Grid>
<ComboBox x:Name="cmbNames" ItemsSource="{Binding SelectedName}" DisplayMemberPath ="FirstName" Width="454">
</ComboBox>
<TextBlock x:Name="txtComboBox" Style="{StaticResource ComboTextBox}"
Visibility="{Binding SelectedItem, ElementName=cmbNames, Converter={StaticResource NullToVisibilityConverter}}"
Text=" Select ..." />
</Grid>
Hopefully someone can look at this temp solution and offer me the solution on how to get rid of the arrow on the combobox.

WPF Telerik RadContextMenu and RadMenuItem:How to remove extra highlighted row from RadMenuItem

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>

WPF TreeViewItem not expanding from code behind

I have the following style defined for a TreeViewItem:
<Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}">
<Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
<Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" />
<Setter Property="AllowDrop" Value="True" />
<Setter Property="Background" Value="Transparent"/>
<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="Padding" Value="1,0,0,0"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TreeViewItem}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="19" Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<!-- Connecting Lines -->
<Rectangle x:Name="HorLn" Height="1" Stroke="#8888" Margin="10,0,0,0" SnapsToDevicePixels="true"/>
<Rectangle x:Name="VerLn" Width="1" Stroke="#8888" Grid.RowSpan="2" SnapsToDevicePixels="true"/>
<ToggleButton x:Name="Expander"
Style="{StaticResource ExpandCollapseToggleStyle}"
IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
ClickMode="Press"/>
<Border Name="Bd"
Grid.Column="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<ContentPresenter x:Name="PART_Header"
ContentSource="Header"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
</Border>
<ItemsPresenter x:Name="ItemsHost"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"/>
</Grid>
<ControlTemplate.Triggers>
<!-- This trigger changes the connecting lines if the item is the last in the list -->
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource LineConverter}}" Value="true">
<Setter TargetName="VerLn"
Property="Height"
Value="6"/>
<Setter TargetName="VerLn"
Property="VerticalAlignment"
Value="Top"/>
</DataTrigger>
<Trigger Property="IsExpanded"
Value="false">
<Setter TargetName="ItemsHost"
Property="Visibility"
Value="Collapsed"/>
</Trigger>
<Trigger Property="HasItems"
Value="false">
<Setter TargetName="Expander"
Property="Visibility"
Value="Hidden"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="HasHeader"
Value="false"/>
<Condition Property="Width"
Value="Auto"/>
</MultiTrigger.Conditions>
<Setter TargetName="PART_Header"
Property="MinWidth"
Value="75"/>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="HasHeader"
Value="false"/>
<Condition Property="Height"
Value="Auto"/>
</MultiTrigger.Conditions>
<Setter TargetName="PART_Header"
Property="MinHeight"
Value="19"/>
</MultiTrigger>
<Trigger Property="IsSelected"
Value="true">
<Setter TargetName="Bd"
Property="Background"
Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected"
Value="true"/>
<Condition Property="IsSelectionActive"
Value="false"/>
</MultiTrigger.Conditions>
<Setter TargetName="Bd"
Property="Background"
Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
</MultiTrigger>
<Trigger Property="IsEnabled"
Value="false">
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I cannot get TreeViewItem to expand, when IsExpanded property of the model is set to true in code behind. However, model IsExpanded property changes when TreeViewItem is expanded from user interface. What am I missing?
Thanks.
I have similar code working, the setting you have above looks fine.
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
Did you raise a PropertyChanged event once you updated the IsExpanded property in your model?

Resources