I am trying to create a menu that appears when right clicking but am not sure how to implement it in WPF and have not found any online info about it. Anyone have a how to link about this? Thank you
Printable View
I am trying to create a menu that appears when right clicking but am not sure how to implement it in WPF and have not found any online info about it. Anyone have a how to link about this? Thank you
Most every control has a ContextMenu collection. All you need to do is add your menu items to it.
Here's an example of adding a context menu to a grid control:
Code:<Grid>
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Command="{x:Static uc:AppCommands.EditShift}" />
<Separator />
<MenuItem Command="{x:Static uc:AppCommands.AddShift}" />
<MenuItem Command="{x:Static uc:AppCommands.DeleteShift}" />
<Separator />
<MenuItem Command="{x:Static uc:AppCommands.MoveUpShift}" />
<MenuItem Command="{x:Static uc:AppCommands.MoveDownShift}" />
<Separator />
<MenuItem Command="{x:Static uc:AppCommands.ClearShiftEmployee}" />
<Separator />
<MenuItem Command="{x:Static uc:AppCommands.SaveTemplate}" />
</ContextMenu>
</Grid.ContextMenu>
<!-- other grid code -->
</Grid>
Thank you Arjay