title: Change behaviour of editable ComboBox
body: <p>I want to change the behaviour of the editable ComboBox. This is the behaviour I want:</p>
  
  <p>Make the TextBox (PART_EditableTextBox) only visible when IsEditable is true <em>and</em> when the ComboBox is open. I've worked this out in the ControlTemplate.Triggers part:</p>
  
  <pre><code>&lt;MultiTrigger&gt;
      &lt;MultiTrigger.Conditions&gt;
          &lt;Condition Property="IsEditable" Value="True" /&gt;
          &lt;Condition Property="IsDropDownOpen" Value="True" /&gt;
      &lt;/MultiTrigger.Conditions&gt;
      &lt;Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible"/&gt;
  &lt;/MultiTrigger&gt;
  </code></pre>
  
  <p>The problem is that when the PART_EditableTextBox is hidden, the content is not shown. So the ComboBox stays blank after I've selected an item. This is only true when IsEditable = true.</p>
  
  <p>Below is the complete ComboBox template code.</p>
  
  <p></p>
  
  <pre><code>&lt;ResourceDictionary.MergedDictionaries&gt;
      &lt;ResourceDictionary Source="Animations.xaml"/&gt;
      &lt;ResourceDictionary Source="Brushes.xaml"/&gt;
  
  &lt;/ResourceDictionary.MergedDictionaries&gt;
  &lt;BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/&gt;
  &lt;ControlTemplate x:Key="EditableComboBoxToggleButton" TargetType="ToggleButton"&gt;
      &lt;ControlTemplate.Resources&gt;
  
      &lt;/ControlTemplate.Resources&gt;
      &lt;Grid&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition /&gt;
              &lt;ColumnDefinition Width="20" /&gt;
          &lt;/Grid.ColumnDefinitions&gt;
  
          &lt;!-- The drop down button on the right --&gt;
          &lt;Border Grid.ColumnSpan="2" BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4"&gt;
              &lt;Border x:Name="Border" Background="{StaticResource ButtonBaseBrush}" BorderBrush="{StaticResource ButtonInnerBorderBrush}" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4"&gt;
                  &lt;Grid&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition Height="0.507*"/&gt;
                          &lt;RowDefinition Height="0.493*"/&gt;
                      &lt;/Grid.RowDefinitions&gt;
                      &lt;Border Opacity="0" HorizontalAlignment="Stretch" x:Name="glow" Width="Auto" Grid.RowSpan="2" CornerRadius="4,4,4,4" Background="{StaticResource ButtonLitBrush}" /&gt;
                      &lt;ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Width="Auto" Grid.RowSpan="2"/&gt;
                      &lt;Border HorizontalAlignment="Stretch" Margin="0,0,0,0" x:Name="shine" Width="Auto" CornerRadius="4,4,0,0" Background="{StaticResource ButtonGlowOverlay}" /&gt;
                  &lt;/Grid&gt;
              &lt;/Border&gt;
          &lt;/Border&gt;
  
          &lt;!-- The white area where the selected item is displayed (also part of the button) --&gt;
          &lt;Border 
    Grid.Column="0"
    CornerRadius="2,0,0,2" 
    Margin="1" 
    Background="{StaticResource WindowBackgroundBrush}" 
    BorderBrush="Black"
    BorderThickness="1" /&gt;
  
          &lt;!-- The down-arrow --&gt;
          &lt;Path 
    x:Name="Arrow"
    Grid.Column="1"     
    Fill="White"
    HorizontalAlignment="Center"
    VerticalAlignment="Center"
    Data="M 0 0 L 4 4 L 8 0 Z"/&gt;
      &lt;/Grid&gt;
      &lt;ControlTemplate.Triggers&gt;
          &lt;Trigger Property="ToggleButton.IsChecked" Value="True"&gt;
              &lt;Setter Property="Opacity" TargetName="shine" Value="0.4"/&gt;
              &lt;Setter Property="Background" TargetName="Border" Value="#DCE38819"/&gt;
              &lt;Setter Property="Visibility" TargetName="glow" Value="Hidden"/&gt;
          &lt;/Trigger&gt;
          &lt;Trigger Property="ToggleButton.IsMouseOver" Value="True"&gt;
              &lt;Trigger.EnterActions&gt;
                  &lt;BeginStoryboard Storyboard="{StaticResource Timeline1}"/&gt;
              &lt;/Trigger.EnterActions&gt;
              &lt;Trigger.ExitActions&gt;
                  &lt;BeginStoryboard x:Name="Timeline2_BeginStoryboard" Storyboard="{StaticResource Timeline2}"/&gt;
              &lt;/Trigger.ExitActions&gt;
          &lt;/Trigger&gt;
      &lt;/ControlTemplate.Triggers&gt;
  &lt;/ControlTemplate&gt;
  
  &lt;ControlTemplate x:Key="ComboBoxTextBox" TargetType="TextBox"&gt;
      &lt;Border x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}" /&gt;
  &lt;/ControlTemplate&gt;
  
  &lt;Style x:Key="EditableGlassComboBox" 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="MinWidth" Value="120"/&gt;
      &lt;Setter Property="MinHeight" Value="20"/&gt;
      &lt;Setter Property="Height" Value="34" /&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="ComboBox"&gt;
                  &lt;Grid&gt;
                      &lt;ToggleButton 
          Name="ToggleButton" 
          Template="{StaticResource EditableComboBoxToggleButton}"
          IsEnabled="{TemplateBinding IsEnabled}"
          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="Stretch" /&gt;
  
                      &lt;TextBox x:Name="PART_EditableTextBox"
          HorizontalAlignment="Stretch"
          VerticalAlignment="Stretch"
          Background="Red"
          Grid.Column="0"
          Style="{x:Null}" 
          Template="{StaticResource ComboBoxTextBox}" 
          FontSize="16"
          Margin="5,5,23,5"
          Focusable="True" 
          Visibility="Collapsed"
          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 WindowBackgroundBrush}"
              BorderThickness="1"
              BorderBrush="{StaticResource ComboItemsBorderBrush}"/&gt;
                              &lt;ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True"&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 SourceName="Popup" Property="Popup.AllowsTransparency" Value="true"&gt;
                          &lt;Setter TargetName="DropDownBorder" Property="CornerRadius" Value="4"/&gt;
                          &lt;Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0"/&gt;
                      &lt;/Trigger&gt;
                      &lt;MultiTrigger&gt;
                          &lt;MultiTrigger.Conditions&gt;
                              &lt;Condition Property="IsEditable" Value="True" /&gt;
                              &lt;Condition Property="IsDropDownOpen" Value="True" /&gt;
                          &lt;/MultiTrigger.Conditions&gt;
                          &lt;Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible"/&gt;
                      &lt;/MultiTrigger&gt;
                  &lt;/ControlTemplate.Triggers&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
      &lt;Style.Triggers&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p></p>