title: WPF Open Combobox popup on Focus or GotFocus
body: <p>I am trying to open the combobox popup when it is focused using Style/Event Trigger</p>
  
  <p>I used the following code in my Combobox control Template:</p>
  
  <pre><code>&lt;ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}"&gt;
          &lt;Grid &gt;
              &lt;ToggleButton Grid.Column="2" Template="{DynamicResource ComboBoxToggleButton}" x:Name="ToggleButton" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/&gt;
              &lt;ContentPresenter  HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="ContentSite" VerticalAlignment="Center" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" IsHitTestVisible="False"/&gt;
              &lt;TextBox Visibility="Hidden" Template="{DynamicResource ComboBoxTextBox}" HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="PART_EditableTextBox" Style="{x:Null}" VerticalAlignment="Center"  Focusable="True" Background="Transparent" IsReadOnly="{TemplateBinding IsReadOnly}"/&gt;
              &lt;Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide"&gt;
                  &lt;Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True"&gt;
                      &lt;Border x:Name="DropDownBorder" Background="{DynamicResource ShadeBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1"/&gt;
                      &lt;ScrollViewer Margin="4,6,4,6"   SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="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="IsMouseOver"  Value="True"&gt;
                  &lt;Setter Property="IsOpen" Value="True" TargetName="Popup"/&gt;
              &lt;/Trigger&gt;
          &lt;/ControlTemplate.Triggers&gt;
      &lt;/ControlTemplate&gt;
  </code></pre>
  
  <p>But nothing happens with this code.
  So I trid the following Event trigger in ControlTemplate.Triggers</p>
  
  <pre><code>&lt;EventTrigger RoutedEvent="UIElement.GotFocus"&gt;
                  &lt;BeginStoryboard&gt;
                      &lt;Storyboard &gt;
                          &lt;BooleanAnimationUsingKeyFrames Storyboard.TargetName="Popup" Storyboard.TargetProperty="IsOpen" FillBehavior="HoldEnd"&gt;
                              &lt;DiscreteBooleanKeyFrame KeyTime="00:00:00"  Value="True" /&gt;
                          &lt;/BooleanAnimationUsingKeyFrames&gt;
                          &lt;/Storyboard&gt;
                  &lt;/BeginStoryboard&gt;
              &lt;/EventTrigger&gt;
              &lt;EventTrigger RoutedEvent="UIElement.LostFocus"&gt;
                  &lt;BeginStoryboard&gt;
                      &lt;Storyboard &gt;
                          &lt;BooleanAnimationUsingKeyFrames Storyboard.TargetName="Popup" Storyboard.TargetProperty="IsOpen" FillBehavior="HoldEnd"&gt;
                              &lt;DiscreteBooleanKeyFrame KeyTime="00:00:00"  Value="False" /&gt;
                          &lt;/BooleanAnimationUsingKeyFrames&gt;
                      &lt;/Storyboard&gt;
                  &lt;/BeginStoryboard&gt;
              &lt;/EventTrigger&gt;
  </code></pre>
  
  <p>Now this helps open the popup on focus, but when I select any item from dropdown the pop up doesnt disappear as usual; it stays open. it closes only after I click somewhere else in the window. Can someone please suggest the proper way to do this
  Thanks in advance</p>