New to Telerik UI for WPFStart a free 30-day trial

Represents a context menu control that allows for the hierarchical organization of elements, each with associated event handlers. This control provides the ability to customize its appearance and behavior using dependency properties such as IsOpen, StaysOpen, and Placement. The context menu can be opened via various events, with control over its positioning relative to associated elements using properties like HorizontalOffset and VerticalOffset. It supports features such as inheriting the DataContext from its associated element, attaching to events, and managing its open/close states through routed events.

Definition

Constructors

Initializes a new instance of the RadContextMenu class.

C#
public RadContextMenu()

Fields

Identifies the AttachOnHandledEvents dependency property.

C#
public static readonly DependencyProperty AttachOnHandledEventsProperty

ClosedEvent

RoutedEvent

Identifies the Closed routed event.

C#
public static readonly RoutedEvent ClosedEvent

ContextMenuProperty

DependencyProperty

Identifies the RadContextMenu attached property.

C#
public static readonly DependencyProperty ContextMenuProperty

EventNameProperty

DependencyProperty

Identifies the EventName dependency property.

C#
public static readonly DependencyProperty EventNameProperty

HorizontalOffsetProperty

DependencyProperty

Identifies the HorizontalOffset dependency property.

C#
public static readonly DependencyProperty HorizontalOffsetProperty

InheritDataContextProperty

DependencyProperty

Identifies the InheritDataContext dependency property.

C#
public static readonly DependencyProperty InheritDataContextProperty

IsOpenProperty

DependencyProperty

Identifies the IsOpen dependency property.

C#
public static readonly DependencyProperty IsOpenProperty

ModifierKeyProperty

DependencyProperty

Identifies the ModifierKey dependency property.

C#
public static readonly DependencyProperty ModifierKeyProperty

OpenedEvent

RoutedEvent

Identifies the Opened routed event.

C#
public static readonly RoutedEvent OpenedEvent

OpeningEvent

RoutedEvent

Identifies the Opening routed event.

C#
public static readonly RoutedEvent OpeningEvent

PlacementProperty

DependencyProperty

Identifies the Placement dependency property.

C#
public static readonly DependencyProperty PlacementProperty

PlacementRectangleProperty

DependencyProperty

Identifies the PlacementRectangle dependency property.

C#
public static readonly DependencyProperty PlacementRectangleProperty

PlacementTargetProperty

DependencyProperty

Identifies the PlacementTarget dependency property.

C#
public static readonly DependencyProperty PlacementTargetProperty

Identifies the RestoreFocusToTargetElement dependency property.

C#
public static readonly DependencyProperty RestoreFocusToTargetElementProperty

Identifies the ShowKeyboardCuesOnOpen dependency property.

C#
public static readonly DependencyProperty ShowKeyboardCuesOnOpenProperty

StaysOpenProperty

DependencyProperty

Identifies the StaysOpen dependency property.

C#
public static readonly DependencyProperty StaysOpenProperty

UIElementProperty

DependencyProperty

Identifies the UIElement read-only dependency property.

C#
public static readonly DependencyProperty UIElementProperty

VerticalOffsetProperty

DependencyProperty

Identifies the VerticalOffset dependency property.

C#
public static readonly DependencyProperty VerticalOffsetProperty

Properties

Gets or sets whether RadContextMenu will open on handled routed events. The default value is false. This is a dependency property.

C#
public bool AttachOnHandledEvents { get; set; }

Gets or sets the name of the event that will open the context menu.

C#
public string EventName { get; set; }
Property Value:

The name of the event.

Gets whether the control supports scrolling.

C#
protected override bool HandlesScrolling { get; }

Get or sets the horizontal distance between the target origin and the popup alignment point. This is a dependency property.

C#
public double HorizontalOffset { get; set; }

Get or sets whether RadContextMenu will inherit DataContext of the element on which it is attached. This is a dependency property.

C#
public bool InheritDataContext { get; set; }

Gets or sets a value that indicates whether the RadContextMenu is visible. This is a dependency property.

C#
[Browsable(false)]
public bool IsOpen { get; set; }

ModifierKey

ModifierKeys

Gets or sets a ModifierKey that should be pressed when EventName event occurs to open the RadContextMenu. This is a dependency property.

C#
public ModifierKeys ModifierKey { get; set; }

Gets the position of the mouse at the moment when the menu was opened relative to the element that caused RadContextMenu to open. Returns Point(double.NaN, double.NaN) if context menu is closed or if the event caused context menu Opened is not Mouse event (e.g. not MouseRightButtonUp, MouseLeftButtonUp, etc.).

C#
public Point MousePosition { get; }

Placement

PlacementMode

Gets or sets the Placement property of a RadContextMenu. This is a dependency property.

C#
public PlacementMode Placement { get; set; }

Gets or sets the area relative to which the context menu is positioned when it opens. This is a dependency property.

C#
public Rect PlacementRectangle { get; set; }

Gets or sets the PlacementTarget. This is a dependency property.

C#
public UIElement PlacementTarget { get; set; }

Gets or sets a value indicating whether the focus should be returned to the target UIElement when menu is closed.

C#
public bool RestoreFocusToTargetElement { get; set; }

Gets or sets a value indicating whether the keyboard cues should be shown when the menu is opened. Default value is null - keyboard cues will be auto shown when the menu is opened through the keyboard. If set to true keyboard cues will be always shown and if set to false will be never shown when opened.

C#
public bool? ShowKeyboardCuesOnOpen { get; set; }

Gets or sets a value that indicates whether the RadContextMenu should close automatically. This is a dependency property.

C#
public bool StaysOpen { get; set; }

UIElement

UIElement

Gets the element on which RadContextMenu is attached.

C#
public UIElement UIElement { get; }

Get or sets the vertical distance between the target origin and the popup alignment point. This is a dependency property.

C#
public double VerticalOffset { get; set; }

Methods

When overridden in a derived class, undoes the effects of the method.

C#
protected override void ClearContainerForItemOverride(DependencyObject element, object item)
Parameters:elementDependencyObject

The container element.

itemobject

The Item.

Overrides: MenuBase.ClearContainerForItemOverride(DependencyObject, object)

Returns the first element of the given type at the click point coordinates.

C#
public T GetClickedElement<T>() where T : FrameworkElement
Returns:

T

Gets the value of the ContextMenu property of the specified element.

C#
public static RadContextMenu GetContextMenu(FrameworkElement element)
Parameters:elementFrameworkElementReturns:

RadContextMenu

Called when the template for the RadContextMenu is applied, allowing customization of the visual presentation of the context menu elements.

C#
public override void OnApplyTemplate()

Called when the Closed event occurs.

C#
protected virtual void OnClosed(RadRoutedEventArgs e)
Parameters:eRadRoutedEventArgs

Creates a new AutomationPeer for this RadContextMenu.

C#
protected override AutomationPeer OnCreateAutomationPeer()
Returns:

AutomationPeer

Raises the event. This method is invoked whenever is set to true internally.

C#
protected override void OnInitialized(EventArgs e)
Parameters:eEventArgs

The RoutedEventArgs that contains the event data.

Invoked when keyboard key is pressed while the element has focus.

C#
protected override void OnKeyDown(KeyEventArgs e)
Parameters:eKeyEventArgs

The KeyEventArgs that contains the event data.

Overrides: MenuBase.OnKeyDown(KeyEventArgs)

Invoked when keyboard key is released while the element has focus.

C#
protected override void OnKeyUp(KeyEventArgs e)
Parameters:eKeyEventArgs

The KeyEventArgs that contains the event data.

Called when the Opened event occurs.

C#
protected virtual void OnOpened(RadRoutedEventArgs e)
Parameters:eRadRoutedEventArgs

Prepares the specified element to display the specified item.

C#
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
Parameters:elementDependencyObject

Element used to display the specified item.

itemobject

Specified item.

Overrides: MenuBase.PrepareContainerForItemOverride(DependencyObject, object)

Sets the value of the ContextMenu property of the specified element.

C#
public static void SetContextMenu(FrameworkElement element, RadContextMenu value)
Parameters:elementFrameworkElementvalueRadContextMenu

Events

Closed

RoutedEventHandler

Occurs when a particular instance of a RadContextMenu closes.

C#
public event RoutedEventHandler Closed

Opened

RoutedEventHandler

Occurs when a particular instance of a RadContextMenu opens.

C#
public event RoutedEventHandler Opened

Occurs before particular instance of RadContextMenu opens. If it is handled then RadContextMenu will not open.

C#
public event RadRoutedEventHandler Opening