RadMenuItem
Represents an item in a RadMenu or RadContextMenu. The RadMenuItem can be configured to display various visual states, handle commands, and accommodate submenu structures. It supports various properties including icons, headers, and checked states, thereby enhancing the flexibility and usability of menu navigation in WPF applications. The class implements ICommandSource interface to facilitate command binding and also inherits from HeaderedItemsControl to organize and manage child items hierarchically. The RadMenuItem is highly customizable through styling and template selection, allowing for tailored UI experiences.
Definition
Namespace:Telerik.Windows.Controls
Assembly:Telerik.Windows.Controls.Navigation.dll
Syntax:
[TelerikToolboxCategory("Navigation")]
public class RadMenuItem : HeaderedItemsControl, ICommandSource
Inheritance: objectRadMenuItem
Derived Classes:
Implements:
Constructors
Initializes a new instance of the RadMenuItem class without menu text or a value.
public RadMenuItem()
Fields
CheckedEvent
RoutedEvent
Identifies the Checked routed event.
public static readonly RoutedEvent CheckedEvent
CheckedIconProperty
DependencyProperty
Identifies the CheckedIcon dependency property.
public static readonly DependencyProperty CheckedIconProperty
CheckedIconTemplateProperty
DependencyProperty
Identifies the CheckedIconTemplate dependency property.
public static readonly DependencyProperty CheckedIconTemplateProperty
ClickEvent
RoutedEvent
Identifies the Click routed event.
public static readonly RoutedEvent ClickEvent
CommandParameterProperty
DependencyProperty
Identifies the CommandParameter dependency property.
public static readonly DependencyProperty CommandParameterProperty
CommandProperty
DependencyProperty
Identifies the Command dependency property.
public static readonly DependencyProperty CommandProperty
CommandTargetProperty
DependencyProperty
Identifies the CommandTarget property.
public static readonly DependencyProperty CommandTargetProperty
DropDownHeightProperty
DependencyProperty
Identifies the DropDownHeight dependency property.
public static readonly DependencyProperty DropDownHeightProperty
DropDownPlacementProperty
DependencyProperty
Identifies the DropDownPlacement dependency property.
public static readonly DependencyProperty DropDownPlacementProperty
DropDownWidthProperty
DependencyProperty
Identifies the DropDownWidth dependency property.
public static readonly DependencyProperty DropDownWidthProperty
IconColumnWidthProperty
DependencyProperty
Identifies the IconColumnWidth dependency property.
public static readonly DependencyProperty IconColumnWidthProperty
IconProperty
DependencyProperty
Identifies the Icon dependency property.
public static readonly DependencyProperty IconProperty
IconTemplateProperty
DependencyProperty
Identifies the IconTemplate dependency property.
public static readonly DependencyProperty IconTemplateProperty
InputGestureTextProperty
DependencyProperty
Identifies the InputGestureText dependency property.
public static readonly DependencyProperty InputGestureTextProperty
IsCheckableProperty
DependencyProperty
Identifies the IsCheckable dependency property.
public static readonly DependencyProperty IsCheckableProperty
IsCheckedProperty
DependencyProperty
Identifies the IsChecked dependency property.
public static readonly DependencyProperty IsCheckedProperty
IsCurrentProperty
DependencyProperty
Identifies the IsCurrent dependency property.
public static readonly DependencyProperty IsCurrentProperty
IsHighlightedProperty
DependencyProperty
Identifies the IsHighlighted dependency property.
public static readonly DependencyProperty IsHighlightedProperty
IsSeparatorProperty
DependencyProperty
Identifies the IsSeparatorProperty dependency property.
public static readonly DependencyProperty IsSeparatorProperty
IsSubmenuOpenProperty
DependencyProperty
Identifies the IsSubmenuOpen dependency property.
public static readonly DependencyProperty IsSubmenuOpenProperty
IsSuspendingPopupAnimationProperty
DependencyProperty
Identifies the IsSuspendingPopupAnimation readonly dependency property.
public static readonly DependencyProperty IsSuspendingPopupAnimationProperty
ItemContainerTemplateSelectorProperty
DependencyProperty
Identifies the ItemContainerTemplateSelector dependency property.
public static readonly DependencyProperty ItemContainerTemplateSelectorProperty
ItemIconPositionProperty
DependencyProperty
Identifies the ItemIconPosition dependency property.
public static readonly DependencyProperty ItemIconPositionProperty
MenuProperty
DependencyProperty
Identifies the Menu readonly dependency property.
public static readonly DependencyProperty MenuProperty
RoleProperty
DependencyProperty
Identifies the Role dependency property.
public static readonly DependencyProperty RoleProperty
SeparatorTemplateKeyProperty
DependencyProperty
Identifies the SeparatorTemplateKey dependency property.
[Obsolete("Since 2013 Q1 this property is not needed. Please use RadMenuSeparatorItem container and set its Template property.", false)]
public static readonly DependencyProperty SeparatorTemplateKeyProperty
StaysOpenOnClickProperty
DependencyProperty
Identifies the StaysOpenOnClick dependency property.
public static readonly DependencyProperty StaysOpenOnClickProperty
SubmenuClosedEvent
RoutedEvent
Identifies the SubmenuClosed routed event.
public static readonly RoutedEvent SubmenuClosedEvent
SubmenuHeaderTemplateKeyProperty
DependencyProperty
Identifies the SubmenuHeaderTemplateKey dependency property.
[Obsolete("Since 2013 Q1 this property is not needed. Please use Template property.", false)]
public static readonly DependencyProperty SubmenuHeaderTemplateKeyProperty
SubmenuItemTemplateKeyProperty
DependencyProperty
Identifies the SubmenuItemTemplateKey dependency property.
[Obsolete("Since 2013 Q1 this property is not needed. Please use Template property.", false)]
public static readonly DependencyProperty SubmenuItemTemplateKeyProperty
SubmenuOpenedEvent
RoutedEvent
Identifies the SubmenuOpened routed event.
public static readonly RoutedEvent SubmenuOpenedEvent
TopLevelHeaderTemplateKeyProperty
DependencyProperty
Identifies the TopLevelHeaderTemplateKey dependency property.
[Obsolete("Since 2013 Q1 this property is not needed. Please use RadMenuRootItem container and set its Template property.", false)]
public static readonly DependencyProperty TopLevelHeaderTemplateKeyProperty
TopLevelItemTemplateKeyProperty
DependencyProperty
Identifies the TopLevelItemTemplateKey dependency property.
[Obsolete("Since 2013 Q1 this property is not needed. Please use RadMenuRootItem container and set its Template property.", false)]
public static readonly DependencyProperty TopLevelItemTemplateKeyProperty
UncheckedEvent
RoutedEvent
Identifies the Unchecked routed event.
public static readonly RoutedEvent UncheckedEvent
Properties
Gets or sets the icon that appears in a RadMenuItem when it is checkable and is checked. This is a dependency property.
public object CheckedIcon { get; set; }
CheckedIconTemplate
DataTemplate
Gets or sets the data template used for the CheckedIcon. This is a dependency property.
public DataTemplate CheckedIconTemplate { get; set; }
Gets the command that will be executed when the command source is invoked.
[TypeConverter(typeof(CommandConverter))]
public ICommand Command { get; set; }
Represents a user defined data value that can be passed to the command when it is executed.
public object CommandParameter { get; set; }
CommandTarget
IInputElement
The object that the command is being executed on.
public IInputElement CommandTarget { get; set; }
Gets or sets the height of the drop-down area.
public double DropDownHeight { get; set; }
Gets or sets the placement of the drop-down area.
public MenuPlacementMode DropDownPlacement { get; set; }
Gets or sets the width of the drop-down area.
public double DropDownWidth { get; set; }
Gets whether the control supports scrolling.
protected override bool HandlesScrolling { get; }
Gets or sets the icon that appears in a RadMenuItem. This is a dependency property.
[SRCategory("Appearance")]
public object Icon { get; set; }
Gets or sets the width of the column that contains the icon.
public double IconColumnWidth { get; set; }
IconTemplate
DataTemplate
Gets or sets the data template used for Icon. This is a dependency property.
public DataTemplate IconTemplate { get; set; }
Gets or sets the text describing an input gesture that will call the command tied to the specified item.
[Bindable(true)]
public string InputGestureText { get; set; }
Gets a value that indicates whether a RadMenuItem can be checked. This is a dependency property.
[SRCategory("Behavior")]
public bool IsCheckable { get; set; }
Gets or sets a value that indicates whether the RadMenuItem is checked. This is a dependency property.
[SRCategory("Appearance")]
public bool IsChecked { get; set; }
True if the RadMenuItem can be selected; otherwise, false.
protected override bool IsEnabledCore { get; }
Gets a value that indicates whether a RadMenuItem is highlighted. This is a dependency property.
[Browsable(false)]
[SRCategory("Appearance")]
public bool IsHighlighted { get; protected set; }
Gets or sets a value indicating whether this instance is a separator.
public bool IsSeparator { get; set; }
Gets a value that indicates whether the submenu of the RadMenuItem is open. This is a dependency property.
[Browsable(false)]
[SRCategory("Appearance")]
public bool IsSubmenuOpen { get; set; }
Gets whether a menu suspends animations on its Popup control.
public bool IsSuspendingPopupAnimation { get; }
ItemContainerTemplateSelector
DataTemplateSelector
Gets or sets the custom logic for choosing a template used to display each item.
public DataTemplateSelector ItemContainerTemplateSelector { get; set; }
Gets or sets the icon position for the icon. This is a dependency property.
public ItemIconPosition ItemIconPosition { get; set; }
Gets the RadMenu for this RadMenuItem. This is a readonly dependency property.
public MenuBase Menu { get; }
Gets a value that indicates the role of a RadMenuItem. This is a dependency property.
[SRCategory("Behavior")]
public MenuItemRole Role { get; }
SeparatorTemplateKey
ControlTemplate
Gets the resource key for a style applied to a RadMenuItem when the RadMenuItem is a separator.
[Obsolete("Since 2013 Q1 this property is not needed. Please use RadMenuSeparatorItem container and set its Template property.", false)]
public ControlTemplate SeparatorTemplateKey { get; set; }
Gets or sets a value that indicates that the submenu in which this RadMenuItem is located should not close when this item is clicked. This is a dependency property.
[SRCategory("Behavior")]
public bool StaysOpenOnClick { get; set; }
SubmenuHeaderTemplateKey
ControlTemplate
Gets the resource key for a style applied to a RadMenuItem when the RadMenuItem is a header of a submenu.
[Obsolete("Since 2013 Q1 this property is not needed. Please use Template property.", false)]
public ControlTemplate SubmenuHeaderTemplateKey { get; set; }
SubmenuItemTemplateKey
ControlTemplate
Gets the resource key for a style applied to a RadMenuItem when the RadMenuItem is a submenu.
[Obsolete("Since 2013 Q1 this property is not needed. Please use Template property.", false)]
public ControlTemplate SubmenuItemTemplateKey { get; set; }
TopLevelHeaderTemplateKey
ControlTemplate
Gets the resource key for a style applied to a RadMenuItem when the RadMenuItem is a header of a top-level menu.
[Obsolete("Since 2013 Q1 this property is not needed. Please use RadMenuRootItem container and set its Template property.", false)]
public ControlTemplate TopLevelHeaderTemplateKey { get; set; }
TopLevelItemTemplateKey
ControlTemplate
Gets the resource key for a style applied to a RadMenuItem when it is a top-level RadMenuItem.
[Obsolete("Since 2013 Q1 this property is not needed. Please use RadMenuRootItem container and set its Template property.", false)]
public ControlTemplate TopLevelItemTemplateKey { get; set; }
Methods
Updates the visual state of the control.
protected virtual void ChangeVisualState(bool useTransitions)
Indicates whether transitions should be used.
Clear the Menu property.
protected override void ClearContainerForItemOverride(DependencyObject element, object item)
Element used to display the specified item.
itemobjectSpecified item.
GetContainerForItemOverride()
DependencyObject
Creates or identifies the element that is used to display the given item.
protected override DependencyObject GetContainerForItemOverride()
DependencyObject
Determines if the specified item is RadMenuItem.
protected override sealed bool IsItemItsOwnContainerOverride(object item)
The item to check.
Returns:True if the item is RadMenuItem; otherwise, false.
Determines if the specified item is RadMenuItem.
protected virtual bool IsItemItsOwnContainerProtected(object item)
The item to check.
Returns:True if the item is RadMenuItem; otherwise, false.
Provides class handling for when an access key that is meaningful for this element is invoked.
protected override void OnAccessKey(AccessKeyEventArgs e)
The event data to the access key event. The event data reports which key was invoked, and indicate whether the System.Windows.Input.AccessKeyManager object that controls the sending of these events also sent this access key invocation to other elements.
When overridden in a derived class, is invoked whenever application code or internal processes (such as a rebuilding layout pass) call .
public override void OnApplyTemplate()
Called when the IsChecked property becomes true.
protected virtual void OnChecked(RoutedEventArgs e)
The event data for the Checked event.
Called when a RadMenuItem is clicked and raises a Click event.
protected virtual void OnClick()
OnCreateAutomationPeer()
AutomationPeer
Provides an appropriate RadMenuItemAutomationPeer implementation for this control, as part of the automation infrastructure.
protected override AutomationPeer OnCreateAutomationPeer()
AutomationPeer
Invoked when an unhandled Keyboard.GotKeyboardFocus attached event reaches an element in its route that is derived from this class.
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
The KeyboardFocusChangedEventArgs that contains the event data.
protected override void OnHeaderTemplateChanged(DataTemplate oldHeaderTemplate, DataTemplate newHeaderTemplate)
protected override void OnHeaderTemplateSelectorChanged(DataTemplateSelector oldHeaderTemplateSelector, DataTemplateSelector newHeaderTemplateSelector)
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.
Called when the focus is no longer on or within a RadMenuItem.
protected override void OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs e)
The event data for the event.
Invoked when the property changes.
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
Information about the change.
Raises the event.
protected override void OnKeyDown(KeyEventArgs e)
The KeyEventArgs instance containing the event data.
Raises the event.
protected override void OnMouseEnter(MouseEventArgs e)
The MouseEventArgs instance containing the event data.
Raises the event.
protected override void OnMouseLeave(MouseEventArgs e)
The MouseEventArgs instance containing the event data.
Raises the event.
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
The MouseButtonEventArgs instance containing the event data.
Raises the event.
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
The MouseButtonEventArgs instance containing the event data.
Raises the event.
protected override void OnMouseMove(MouseEventArgs e)
The MouseEventArgs instance containing the event data.
Handles MouseRightButtonDown event.
protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
The MouseButtonEventArgs that contains the event data. The event data reports that the right mouse button was pressed.
Handles MouseRightButtonUp event.
protected override void OnMouseRightButtonUp(MouseButtonEventArgs e)
The MouseButtonEventArgs that contains the event data. The event data reports that the right mouse button was released.
Called when the submenu of a RadMenuItem is closed.
protected virtual void OnSubmenuClosed(RadRoutedEventArgs e)
The event data for the SubmenuClosed event.
Called when the submenu of a RadMenuItem is opened.
protected virtual void OnSubmenuOpened(RadRoutedEventArgs e)
The event data for the SubmenuOpened event.
Called when the IsChecked property becomes false.
protected virtual void OnUnchecked(RoutedEventArgs e)
The event data for the Unchecked event.
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.
Resets the theme.
public void ResetTheme()
Events
Checked
RoutedEventHandler
Occurs when a RadMenuItem is checked.
[SRCategory("Behavior")]
public event RoutedEventHandler Checked
Occurs when a RadMenuItem is clicked.
[SRCategory("Behavior")]
public event RadRoutedEventHandler Click
Occurs when the state of the IsSubmenuOpen property changes to false.
[SRCategory("Behavior")]
public event RadRoutedEventHandler SubmenuClosed
Occurs when the state of the IsSubmenuOpen property changes to true.
[SRCategory("Behavior")]
public event RadRoutedEventHandler SubmenuOpened
Unchecked
RoutedEventHandler
Occurs when a RadMenuItem is unchecked.
[SRCategory("Behavior")]
public event RoutedEventHandler Unchecked