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:
[TelerikToolboxCategory("Navigation")]
public class RadContextMenu : MenuBase
Inheritance: objectMenuBaseRadContextMenu
Derived Classes:
Inherited Members
Constructors
Initializes a new instance of the RadContextMenu class.
public RadContextMenu()
Fields
AttachOnHandledEventsProperty
DependencyProperty
Identifies the AttachOnHandledEvents dependency property.
public static readonly DependencyProperty AttachOnHandledEventsProperty
ClosedEvent
RoutedEvent
Identifies the Closed routed event.
public static readonly RoutedEvent ClosedEvent
ContextMenuProperty
DependencyProperty
Identifies the RadContextMenu attached property.
public static readonly DependencyProperty ContextMenuProperty
EventNameProperty
DependencyProperty
Identifies the EventName dependency property.
public static readonly DependencyProperty EventNameProperty
HorizontalOffsetProperty
DependencyProperty
Identifies the HorizontalOffset dependency property.
public static readonly DependencyProperty HorizontalOffsetProperty
InheritDataContextProperty
DependencyProperty
Identifies the InheritDataContext dependency property.
public static readonly DependencyProperty InheritDataContextProperty
IsOpenProperty
DependencyProperty
Identifies the IsOpen dependency property.
public static readonly DependencyProperty IsOpenProperty
ModifierKeyProperty
DependencyProperty
Identifies the ModifierKey dependency property.
public static readonly DependencyProperty ModifierKeyProperty
OpenedEvent
RoutedEvent
Identifies the Opened routed event.
public static readonly RoutedEvent OpenedEvent
OpeningEvent
RoutedEvent
Identifies the Opening routed event.
public static readonly RoutedEvent OpeningEvent
PlacementProperty
DependencyProperty
Identifies the Placement dependency property.
public static readonly DependencyProperty PlacementProperty
PlacementRectangleProperty
DependencyProperty
Identifies the PlacementRectangle dependency property.
public static readonly DependencyProperty PlacementRectangleProperty
PlacementTargetProperty
DependencyProperty
Identifies the PlacementTarget dependency property.
public static readonly DependencyProperty PlacementTargetProperty
RestoreFocusToTargetElementProperty
DependencyProperty
Identifies the RestoreFocusToTargetElement dependency property.
public static readonly DependencyProperty RestoreFocusToTargetElementProperty
ShowKeyboardCuesOnOpenProperty
DependencyProperty
Identifies the ShowKeyboardCuesOnOpen dependency property.
public static readonly DependencyProperty ShowKeyboardCuesOnOpenProperty
StaysOpenProperty
DependencyProperty
Identifies the StaysOpen dependency property.
public static readonly DependencyProperty StaysOpenProperty
UIElementProperty
DependencyProperty
Identifies the UIElement read-only dependency property.
public static readonly DependencyProperty UIElementProperty
VerticalOffsetProperty
DependencyProperty
Identifies the VerticalOffset dependency property.
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.
public bool AttachOnHandledEvents { get; set; }
Gets or sets the name of the event that will open the context menu.
public string EventName { get; set; }
The name of the event.
Gets whether the control supports scrolling.
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.
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.
public bool InheritDataContext { get; set; }
Gets or sets a value that indicates whether the RadContextMenu is visible. This is a dependency property.
[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.
public ModifierKeys ModifierKey { get; set; }
MousePosition
Point
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.).
public Point MousePosition { get; }
Placement
PlacementMode
Gets or sets the Placement property of a RadContextMenu. This is a dependency property.
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.
public Rect PlacementRectangle { get; set; }
PlacementTarget
UIElement
Gets or sets the PlacementTarget. This is a dependency property.
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.
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.
public bool? ShowKeyboardCuesOnOpen { get; set; }
Gets or sets a value that indicates whether the RadContextMenu should close automatically. This is a dependency property.
public bool StaysOpen { get; set; }
UIElement
UIElement
Gets the element on which RadContextMenu is attached.
public UIElement UIElement { get; }
Get or sets the vertical distance between the target origin and the popup alignment point. This is a dependency property.
public double VerticalOffset { get; set; }
Methods
When overridden in a derived class, undoes the effects of the method.
protected override void ClearContainerForItemOverride(DependencyObject element, object item)
The container element.
itemobjectThe Item.
Overrides:
Returns the first element of the given type at the click point coordinates.
public T GetClickedElement<T>() where T : FrameworkElement
T
Gets the value of the ContextMenu property of the specified element.
public static RadContextMenu GetContextMenu(FrameworkElement element)
Called when the template for the RadContextMenu is applied, allowing customization of the visual presentation of the context menu elements.
public override void OnApplyTemplate()
Called when the Closed event occurs.
OnCreateAutomationPeer()
AutomationPeer
Creates a new AutomationPeer for this RadContextMenu.
protected override AutomationPeer OnCreateAutomationPeer()
AutomationPeer
Raises the event. This method is invoked whenever is set to true internally.
protected override void OnInitialized(EventArgs e)
The RoutedEventArgs that contains the event data.
Invoked when keyboard key is pressed while the element has focus.
protected override void OnKeyDown(KeyEventArgs e)
The KeyEventArgs that contains the event data.
Overrides:
Invoked when keyboard key is released while the element has focus.
protected override void OnKeyUp(KeyEventArgs e)
The KeyEventArgs that contains the event data.
Called when the Opened event occurs.
Prepares the specified element to display the specified item.
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
Element used to display the specified item.
itemobjectSpecified item.
Overrides:
Sets the value of the ContextMenu property of the specified element.
public static void SetContextMenu(FrameworkElement element, RadContextMenu value)
Events
Closed
RoutedEventHandler
Occurs when a particular instance of a RadContextMenu closes.
public event RoutedEventHandler Closed
Opened
RoutedEventHandler
Occurs when a particular instance of a RadContextMenu opens.
public event RoutedEventHandler Opened
Occurs before particular instance of RadContextMenu opens. If it is handled then RadContextMenu will not open.
public event RadRoutedEventHandler Opening