title: WPF Button with ContextMenu under left click
body: <p>I have small problem with ContextMenu.</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;Style x:Key="ButtonWithContextMenuStyle" TargetType="Button"&gt;
          &lt;Setter Property="Background" Value="#cbeb00" /&gt;
          &lt;Setter Property="Foreground" Value="#505050" /&gt;
          &lt;Setter Property="FontSize" Value="12" /&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="Button"&gt;
                      &lt;Border CornerRadius="4" Background="{TemplateBinding Background}"
                              BorderThickness="0"&gt;
                          &lt;ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Margin="{TemplateBinding Padding}" /&gt;
                      &lt;/Border&gt;
                      &lt;ControlTemplate.Triggers&gt;
                          &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                              &lt;Setter Property="Background" Value="#aaaaaa"/&gt;
                              &lt;Setter Property="Foreground" Value="#dcff00"/&gt;
                          &lt;/Trigger&gt;
                      &lt;/ControlTemplate.Triggers&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Setter Property="ContextMenu"&gt;
              &lt;Setter.Value&gt;
                  &lt;ContextMenu&gt;
                      &lt;MenuItem Command="{Binding EditUserCommand}" Header="{DynamicResource EditUserContextMenuMW}"/&gt;
                      &lt;MenuItem Command="{Binding OpenHistoryCommand}" Header="{DynamicResource ConversationHistoryContextMenuMW}"/&gt;
                      &lt;MenuItem Command="{Binding OpenHistoryCommand}" Header="{DynamicResource BuyCreditContextMenuMW}"/&gt;
                      &lt;Separator /&gt;
                      &lt;MenuItem Command="{Binding LogoutCommand}" Header="{DynamicResource LogoutContextMenuMW}"/&gt;
                  &lt;/ContextMenu&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Style.Triggers&gt;
              &lt;EventTrigger RoutedEvent="Click" &gt;
                  &lt;EventTrigger.Actions&gt;
                      &lt;BeginStoryboard&gt;
                          &lt;Storyboard&gt;
                              &lt;BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="ContextMenu.IsOpen"&gt;
                                  &lt;DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="True"/&gt;
                              &lt;/BooleanAnimationUsingKeyFrames&gt;
                          &lt;/Storyboard&gt;
                      &lt;/BeginStoryboard&gt;
                  &lt;/EventTrigger.Actions&gt;
              &lt;/EventTrigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
  &lt;/Window.Resources&gt;
  </code></pre>
  
  <p>When I click right mouse button, everything work correctly. ContextMenu opens and i can invoke Command on MenuItem. </p>
  
  <p>I would like to see the same behavior when I click the left mouse button. However, only the ContextMenu opens, and I can not call Command.</p>
  
  <p>Can someone tell me what am I doing wrong?</p>