title: WPF template overridden when custom style applied
body: <p>I have a global style defined for a combobox in app.xaml as below: </p>
  
  <pre><code>&lt;Style x:Key="{x:Type ComboBox}" TargetType="ComboBox"&gt;
      &lt;Setter Property="SnapsToDevicePixels" Value="true"/&gt;
      &lt;Setter Property="OverridesDefaultStyle" Value="true"/&gt;
      &lt;Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/&gt;
      &lt;Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/&gt;
      &lt;Setter Property="ScrollViewer.CanContentScroll" Value="true"/&gt;
      &lt;Setter Property="MinHeight" Value="20"/&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="ComboBox"&gt;
                  &lt;Grid Width="{TemplateBinding Width}"&gt;
                      &lt;ToggleButton 
                                          Name="ToggleButton" 
                                          Template="{StaticResource ComboBoxToggleButton}" 
                                          Grid.Column="2" 
                                          Focusable="false"
                                          IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
                                          ClickMode="Press"&gt;
                      &lt;/ToggleButton&gt;
                      &lt;ContentPresenter
                                          Name="ContentSite"
                                          IsHitTestVisible="False" 
                                          Content="{TemplateBinding SelectionBoxItem}"
                                          ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                          Margin="3,3,23,3"
                                          VerticalAlignment="Center"
                                          HorizontalAlignment="Left" /&gt;
                      &lt;TextBox x:Name="PART_EditableTextBox"
                                          Style="{x:Null}" 
                                          Template="{StaticResource ComboBoxTextBox}" 
                                          HorizontalAlignment="Left" 
                                          VerticalAlignment="Center" 
                                          Margin="3,3,23,3"
                                          Focusable="True" 
                                          Background="Transparent"
                                          Visibility="Hidden"
                                          IsReadOnly="{TemplateBinding IsReadOnly}"/&gt;
                      &lt;Popup 
                                          Name="Popup"
                                          Placement="Bottom"
                                          IsOpen="{TemplateBinding IsDropDownOpen}"
                                          AllowsTransparency="True" 
                                          Focusable="False"
                                          PopupAnimation="Slide"&gt;
                          &lt;Grid 
                                              Name="DropDown"
                                              SnapsToDevicePixels="True"                
                                              MinWidth="{TemplateBinding ActualWidth}"
                                              MaxHeight="{TemplateBinding MaxDropDownHeight}"&gt;
                              &lt;Border x:Name="DropDownBorder" Background="{StaticResource BackgroundBrush}" /&gt;
                              &lt;ScrollViewer Margin="4,4,4,4" SnapsToDevicePixels="True" Style="{StaticResource DropDownScrollViewer}"&gt;
                                  &lt;StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" /&gt;
                              &lt;/ScrollViewer&gt;
                          &lt;/Grid&gt;
                      &lt;/Popup&gt;
                  &lt;/Grid&gt;
                  &lt;ControlTemplate.Triggers&gt;
                      &lt;Trigger Property="HasItems" Value="false"&gt;
                          &lt;Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/&gt;
                      &lt;/Trigger&gt;
                      &lt;Trigger Property="IsEnabled" Value="false"&gt;
                          &lt;Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/&gt;
                      &lt;/Trigger&gt;
                      &lt;Trigger Property="IsGrouping" Value="true"&gt;
                          &lt;Setter Property="ScrollViewer.CanContentScroll" Value="false"/&gt;
                      &lt;/Trigger&gt;
                      &lt;Trigger Property="IsEditable" Value="true"&gt;
                          &lt;Setter Property="IsTabStop" Value="false"/&gt;
                          &lt;Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible"/&gt;
                          &lt;Setter TargetName="ContentSite" Property="Visibility" Value="Hidden"/&gt;
                      &lt;/Trigger&gt;
                  &lt;/ControlTemplate.Triggers&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Then I create a combobox in a control:</p>
  
  <pre><code>&lt;ComboBox Name="DataTypeSelector" ItemsSource="{Binding ElementName=DataItemsBuildWindow, Path=DataContext.Types}" SelectedValue="{Binding DataType}" HorizontalAlignment="Stretch" /&gt;                                      
  </code></pre>
  
  <p>The style is applied as expected. </p>
  
  <p>If I change my combobox in the control to the below, the combobox goes back to its original style and the width and triggers defined work. It seems that the new global style is ignored.</p>
  
  <pre><code>&lt;ComboBox Name="DataTypeSelector" ItemsSource="{Binding ElementName=DataItemsBuildWindow, Path=DataContext.Types}" SelectedValue="{Binding DataType}" HorizontalAlignment="Stretch"&gt;
                                      &lt;ComboBox.Style&gt;
                                          &lt;Style TargetType="ComboBox"&gt;
                                              &lt;Setter Property="Width" Value="160"&gt;&lt;/Setter&gt;
                                              &lt;Style.Triggers&gt;
                                                  &lt;DataTrigger Value="List" Binding="{Binding SelectedValue, ElementName=DataTypeSelector, Converter={StaticResource ToStringConverter}}"&gt;
                                                      &lt;Setter Property="Width" Value="80" /&gt;
                                                  &lt;/DataTrigger&gt;
                                              &lt;/Style.Triggers&gt;
                                          &lt;/Style&gt;
                                      &lt;/ComboBox.Style&gt;
                                  &lt;/ComboBox&gt;
  </code></pre>
  
  <p>How can I keep the global style but also apply the custom triggers?</p>