Class
RadContextMenu

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

Namespace:Telerik.Windows.Controls

Assembly:Telerik.Windows.Controls.Navigation.dll

Syntax:

cs-api-definition
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
[TelerikToolboxCategory("Navigation")]
public class RadContextMenu : MenuBase

Inheritance: objectMenuBaseRadContextMenu

Derived Classes: OverflowMenuDropDownMenu

Inherited Members MenuBase.ItemContainerTemplateSelectorPropertyMenuBase.IconColumnWidthPropertyMenuBase.ClickToOpenPropertyMenuBase.ShowDelayPropertyMenuBase.HideDelayPropertyMenuBase.NotifyOnHeaderClickPropertyMenuBase.OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs)MenuBase.GetContainerForItemOverride()MenuBase.IsItemItsOwnContainerOverride(object)MenuBase.IsItemItsOwnContainerProtected(object)MenuBase.OnItemClick(RadRoutedEventArgs)MenuBase.OnLoaded(RoutedEventArgs)MenuBase.NotifyOnHeaderClickMenuBase.ClickToOpenMenuBase.IconColumnWidthMenuBase.ShowDelayMenuBase.HideDelayMenuBase.ItemContainerTemplateSelectorMenuBase.ItemClick

Constructors

RadContextMenu()

Initializes a new instance of the RadContextMenu class.

Declaration

cs-api-definition
public RadContextMenu()

Fields

AttachOnHandledEventsProperty

Identifies the AttachOnHandledEvents dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty AttachOnHandledEventsProperty

Field Value

DependencyProperty

ClosedEvent

Identifies the Closed routed event.

Declaration

cs-api-definition
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
public static readonly RoutedEvent ClosedEvent

Field Value

RoutedEvent

ContextMenuProperty

Identifies the RadContextMenu attached property.

Declaration

cs-api-definition
public static readonly DependencyProperty ContextMenuProperty

Field Value

DependencyProperty

EventNameProperty

Identifies the EventName dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty EventNameProperty

Field Value

DependencyProperty

HorizontalOffsetProperty

Identifies the HorizontalOffset dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty HorizontalOffsetProperty

Field Value

DependencyProperty

InheritDataContextProperty

Identifies the InheritDataContext dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty InheritDataContextProperty

Field Value

DependencyProperty

IsOpenProperty

Identifies the IsOpen dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty IsOpenProperty

Field Value

DependencyProperty

ModifierKeyProperty

Identifies the ModifierKey dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty ModifierKeyProperty

Field Value

DependencyProperty

OpenedEvent

Identifies the Opened routed event.

Declaration

cs-api-definition
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
public static readonly RoutedEvent OpenedEvent

Field Value

RoutedEvent

OpeningEvent

Identifies the Opening routed event.

Declaration

cs-api-definition
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
public static readonly RoutedEvent OpeningEvent

Field Value

RoutedEvent

PlacementProperty

Identifies the Placement dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty PlacementProperty

Field Value

DependencyProperty

PlacementRectangleProperty

Identifies the PlacementRectangle dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty PlacementRectangleProperty

Field Value

DependencyProperty

PlacementTargetProperty

Identifies the PlacementTarget dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty PlacementTargetProperty

Field Value

DependencyProperty

RestoreFocusToTargetElementProperty

Identifies the RestoreFocusToTargetElement dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty RestoreFocusToTargetElementProperty

Field Value

DependencyProperty

ShowKeyboardCuesOnOpenProperty

Identifies the ShowKeyboardCuesOnOpen dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty ShowKeyboardCuesOnOpenProperty

Field Value

DependencyProperty

StaysOpenProperty

Identifies the StaysOpen dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty StaysOpenProperty

Field Value

DependencyProperty

UIElementProperty

Identifies the UIElement read-only dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty UIElementProperty

Field Value

DependencyProperty

VerticalOffsetProperty

Identifies the VerticalOffset dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty VerticalOffsetProperty

Field Value

DependencyProperty

Properties

AttachOnHandledEvents

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

Declaration

cs-api-definition
public bool AttachOnHandledEvents { get; set; }

Property Value

bool

EventName

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

Declaration

cs-api-definition
public string EventName { get; set; }

Property Value

string

The name of the event.

HandlesScrolling

Gets whether the control supports scrolling.

Declaration

cs-api-definition
protected override bool HandlesScrolling { get; }

Property Value

bool

HorizontalOffset

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

Declaration

cs-api-definition
public double HorizontalOffset { get; set; }

Property Value

double

InheritDataContext

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

Declaration

cs-api-definition
public bool InheritDataContext { get; set; }

Property Value

bool

IsOpen

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

Declaration

cs-api-definition
[Browsable(false)]
public bool IsOpen { get; set; }

Property Value

bool

ModifierKey

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

Declaration

cs-api-definition
public ModifierKeys ModifierKey { get; set; }

Property Value

ModifierKeys

MousePosition

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.).

Declaration

cs-api-definition
public Point MousePosition { get; }

Property Value

Point

Placement

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

Declaration

cs-api-definition
public PlacementMode Placement { get; set; }

Property Value

PlacementMode

PlacementRectangle

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

Declaration

cs-api-definition
public Rect PlacementRectangle { get; set; }

Property Value

Rect

PlacementTarget

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

Declaration

cs-api-definition
public UIElement PlacementTarget { get; set; }

Property Value

UIElement

RestoreFocusToTargetElement

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

Declaration

cs-api-definition
public bool RestoreFocusToTargetElement { get; set; }

Property Value

bool

ShowKeyboardCuesOnOpen

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.

Declaration

cs-api-definition
public bool? ShowKeyboardCuesOnOpen { get; set; }

Property Value

bool?

StaysOpen

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

Declaration

cs-api-definition
public bool StaysOpen { get; set; }

Property Value

bool

UIElement

Gets the element on which RadContextMenu is attached.

Declaration

cs-api-definition
public UIElement UIElement { get; }

Property Value

UIElement

VerticalOffset

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

Declaration

cs-api-definition
public double VerticalOffset { get; set; }

Property Value

double

Methods

ClearContainerForItemOverride(DependencyObject, object)

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

Declaration

cs-api-definition
protected override void ClearContainerForItemOverride(DependencyObject element, object item)

Parameters

element

DependencyObject

The container element.

item

object

The Item.

Overrides MenuBase.ClearContainerForItemOverride(DependencyObject, object)

GetClickedElement<T>()

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

Declaration

cs-api-definition
public T GetClickedElement<T>() where T : FrameworkElement

Returns

T

GetContextMenu(FrameworkElement)

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

Declaration

cs-api-definition
[SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Only FrameworkElement are allowed.")]
public static RadContextMenu GetContextMenu(FrameworkElement element)

Parameters

element

FrameworkElement

Returns

RadContextMenu

OnApplyTemplate()

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

Declaration

cs-api-definition
public override void OnApplyTemplate()

OnClosed(RadRoutedEventArgs)

Called when the Closed event occurs.

Declaration

cs-api-definition
protected virtual void OnClosed(RadRoutedEventArgs e)

Parameters

e

RadRoutedEventArgs

OnCreateAutomationPeer()

Creates a new AutomationPeer for this RadContextMenu.

Declaration

cs-api-definition
protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer

OnInitialized(EventArgs)

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

Declaration

cs-api-definition
protected override void OnInitialized(EventArgs e)

Parameters

e

EventArgs

The RoutedEventArgs that contains the event data.

OnKeyDown(KeyEventArgs)

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

Declaration

cs-api-definition
protected override void OnKeyDown(KeyEventArgs e)

Parameters

e

KeyEventArgs

The KeyEventArgs that contains the event data.

Overrides MenuBase.OnKeyDown(KeyEventArgs)

OnKeyUp(KeyEventArgs)

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

Declaration

cs-api-definition
protected override void OnKeyUp(KeyEventArgs e)

Parameters

e

KeyEventArgs

The KeyEventArgs that contains the event data.

OnOpened(RadRoutedEventArgs)

Called when the Opened event occurs.

Declaration

cs-api-definition
protected virtual void OnOpened(RadRoutedEventArgs e)

Parameters

e

RadRoutedEventArgs

PrepareContainerForItemOverride(DependencyObject, object)

Prepares the specified element to display the specified item.

Declaration

cs-api-definition
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)

Parameters

element

DependencyObject

Element used to display the specified item.

item

object

Specified item.

Overrides MenuBase.PrepareContainerForItemOverride(DependencyObject, object)

SetContextMenu(FrameworkElement, RadContextMenu)

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

Declaration

cs-api-definition
[SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Only FrameworkElement are allowed.")]
public static void SetContextMenu(FrameworkElement element, RadContextMenu value)

Parameters

element

FrameworkElement

value

RadContextMenu

Events

Closed

Occurs when a particular instance of a RadContextMenu closes.

Declaration

cs-api-definition
public event RoutedEventHandler Closed

Event Value

RoutedEventHandler

Opened

Occurs when a particular instance of a RadContextMenu opens.

Declaration

cs-api-definition
public event RoutedEventHandler Opened

Event Value

RoutedEventHandler

Opening

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

Declaration

cs-api-definition
public event RadRoutedEventHandler Opening

Event Value

RadRoutedEventHandler