Mike, I took your template and nested it in the mine using a text box, however I got the arrow back into the comboBox, which I really wanted to avoid. But itβs good that I deleted the text box inside the combobox template and was able to delete this other template .... (all this is shown as a comment)
<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="White" /> </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" /> <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> </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>
Now this works by setting ToogleButton in the ControlTemplate for both triggers 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 function used with the list:
<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 workaround and offer me a solution on how to get rid of the arrow in the combo box.