I have small problem with ContextMenu.
<Window.Resources>
<Style x:Key="ButtonWithContextMenuStyle" TargetType="Button">
<Setter Property="Background" Value="#cbeb00" />
<Setter Property="Foreground" Value="#505050" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border CornerRadius="4" Background="{TemplateBinding Background}"
BorderThickness="0">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Margin="{TemplateBinding Padding}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#aaaaaa"/>
<Setter Property="Foreground" Value="#dcff00"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Command="{Binding EditUserCommand}" Header="{DynamicResource EditUserContextMenuMW}"/>
<MenuItem Command="{Binding OpenHistoryCommand}" Header="{DynamicResource ConversationHistoryContextMenuMW}"/>
<MenuItem Command="{Binding OpenHistoryCommand}" Header="{DynamicResource BuyCreditContextMenuMW}"/>
<Separator />
<MenuItem Command="{Binding LogoutCommand}" Header="{DynamicResource LogoutContextMenuMW}"/>
</ContextMenu>
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="Click" >
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="ContextMenu.IsOpen">
<DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="True"/>
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
When I click right mouse button, everything work correctly. ContextMenu opens and i can invoke Command on MenuItem.
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.
Can someone tell me what am I doing wrong?