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