You can create a new template for the button and then provide a context menu in the template's visual tree. Something like this:
<Style TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<Border.ContextMenu>
<ContextMenu Name="contextMenu">
<MenuItem Header="Here's a menu."/>
</ContextMenu>
</Border.ContextMenu>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
You could then trigger using the IsPressed
property of the button and hook it up using a setter with contextMenu as the TargetName
.
My real question is, what are you using this for? Opening a context-menu on left-click is going to be inherently flawed, because context-menus, by their nature, close when any other element is clicked. Which means this trigger, even when properly set up, will simply open and close the context menu immediately. I am curious as to why you need this kind of behavior; perhaps there is a better way of doing it than using a context-menu.