Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This example shows how to use the ContextMenuService.
The ContextMenuService defines a number of properties and events that control the display and event operations of a ContextMenu. These properties are used by attaching them directly to the element where you want to expose the ContextMenu. These services allow a ContextMenu to appear for controls that are disabled and will not have events routed to them.
The code sample shows how to display a ContextMenu for a Button that is disabled.
Example
<Button Height="30" Content="Disabled Button" IsEnabled="False"
ContextMenuService.ShowOnDisabled="True">
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header="Item 1"/>
<MenuItem Header="Item 2"/>
<MenuItem Header="Item 3"/>
</ContextMenu>
</Button.ContextMenu>
</Button>
For the complete sample see ContextMenu Sample.