Export (0) Print
Expand All

FrameworkContentElement.ContextMenuOpening Event

Occurs when any context menu on the element is opened.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public event ContextMenuEventHandler ContextMenuOpening
<object ContextMenuOpening="ContextMenuEventHandler" .../>

Identifier field

ContextMenuOpeningEvent

Routing strategy

Bubbling

Delegate

ContextMenuEventHandler

To manually open context menus, handlers of the events should mark the relevant event as handled. Otherwise, the existing value of the ContextMenu property will be used to automatically open a context menu. Marking the event handled will effectively cancel the default action, and could be an opportunity to reset the value of the ContextMenu property and then open the new ContextMenu. However, there is a timing issue you should be aware of. In order to completely replace the context menu through a ContextMenuOpening handler, the initial context menu must not be null / empty. Alternatively, you might need to handle the event and then manually open a new context menu. For details, see How to: Handle the ContextMenuOpening Event.

To use this event as an EventTrigger in a style, you must reference the underlying service event identifier:

<EventTrigger RoutedEvent="ContextMenuService.ContextMenuOpening">
  <!-- storyboard here ... -->
</EventTrigger>

(This usage is required because the event implementation on FrameworkContentElement that exposes the underlying service event does not correctly map the ContextMenuOpening identifier for use in triggers).

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft