Class MenuItem
Represents an individual item that is displayed within a menu.
[ControlCategory("Hidden")]
public class MenuItem : Menu, IBaseObjectWithAttr, IDisposableObject, IComponent, IDisposable, ICommandSource, IMenuItemProperties, IMenuProperties, ICollectionObserver<object>, INotifyPropertyChanged, IBaseObjectWithId, IBaseObject
- Inheritance
-
MenuItem
- Implements
- Derived
Constructors
- MenuItem()
Initializes a new instance of the MenuItem class.
- MenuItem(string?)
Initializes a new instance of the MenuItem class with the specified
textfor the menu item.
- MenuItem(string?, Image?, EventHandler)
Initializes a new instance of the MenuItem class that displays the specified text and image and that does the specified action when the MenuItem is clicked.
- MenuItem(string?, KeyGesture)
Initializes a new instance of the MenuItem class with the specified
textandshortcutfor the menu item.
- MenuItem(string?, Action?)
Initializes a new instance of the MenuItem class with the specified
textandonClickfor the menu item.
- MenuItem(string?, Action?, KeyGesture?)
Initializes a new instance of the MenuItem class with the specified
text,onClickandshortcutfor the menu item.
- MenuItem(string?, EventHandler?, KeyGesture?)
Initializes a new instance of the MenuItem class with the specified
text,onClickandshortcutfor the menu item.
- MenuItem(string?, Func<bool>?)
Initializes a new instance of the MenuItem class with the specified
textandonClickfor the menu item.
Fields
- DefaultMenuArrowImageSize
Represents the default size of the menu arrow image.
Properties
- AttachedWindow
Gets the Window instance to which this menu item is attached, if any.
- Checked
Gets or sets a value indicating whether a check mark appears next to the text of the menu item.
- ClickAction
Gets or sets Action which will be executed when this MenuItem is clicked by the user.
- Command
The command that will be executed when the class is "invoked". Classes that implement this interface should enable or disable based on the command's CanExecute(object?) return value.
- CommandParameter
Gets the parameter that will be passed to the command when executing it.
- CommandTarget
An element that an implementor may wish to target as the destination for the command. The property may be implemented as read-write if desired.
- DefaultMenuArrowImage
Gets or sets the default arrow image which is shown when menu item has a submenu.
- DisabledImage
Gets or sets disabled image associated with the menu item.
- Enabled
Gets or sets a value indicating whether the menu item is enabled.
- EnabledFunc
Gets or sets function which is called inside OnOpening(CancelEventArgs) in order to update enabled state.
- HasContextMenuParent
Gets a value indicating whether this menu item is attached to a ContextMenu.
- HasMainMenuInParents
Gets a value indicating whether a MainMenu exists in the logical parent hierarchy of this element.
- HasMainMenuParent
Gets a value indicating whether this menu item is attached to a MainMenu.
- HasMenuParent
Gets a value indicating whether this menu item is attached to a Menu.
- IndexInParent
Gets the index in the items of the container.
- IsEnabled
Gets or sets a value indicating whether the menu item is enabled.
- IsLastInParent
Gets a value indicating whether this item is the last child in its parent menu.
- IsLastVisibleInParent
Gets a value indicating whether this item is the last visible item in its parent menu.
- IsSeparator
Gets a value indicating whether the text represents a separator.
- IsShortcutEnabled
Gets or sets whether Shortcut is enabled.
- IsTextLocalized
Gets or sets whether Text property should be localizable.
- ItemsMenu
Gets the menu with the child menu-items.
- NextVisibleSibling
Gets next visible sibling item.
- PreviousVisibleSibling
Gets previous visible sibling item.
- Role
Gets or sets this menu item's role, which is used to automate macOS-specific standard items layout.
- Shortcut
Gets or sets a value indicating the associated shortcut key.
- ShortcutInfo
Gets or sets a value indicating the associated shortcut key.
- ShortcutKeyInfo
Gets or sets a value indicating the associated shortcut key.
- ShortcutKeys
Gets or sets the associated shortcut keys.
- SvgImageSize
Gets or sets size of the svg image.
- Text
Gets or sets a value indicating the caption of the menu item.
- TopLevelMenuItem
Gets the top-level MenuItem in the logical parent hierarchy, if one exists. This method uses the LogicalParents property to traverse the hierarchy.
- Visible
Gets or sets a value indicating whether the menu item is visible.
Methods
- Assign(IMenuItemProperties)
Copies the properties from the specified source to the current instance.
- CommandSourceCanExecute()
Determines whether the command source can currently execute its associated command.
- DisposeManaged()
Override to dispose managed resources. Here we dispose all used object references.
- GetRealImage(VisualControlState, bool?, Control?)
Gets real menu image for the specified state constructed from the following properties: Image, DisabledImage, SvgImage, SvgImageSize.
- OnClick(EventArgs)
Called when menu item is clicked.
- OnEnabledChanged(EventArgs)
Called when the enabled of the Enabled property changes.
- OnTextChanged(EventArgs)
Called when the TextChanged event is raised.
- OnVisibleChanged(EventArgs)
Called when the value of the Visible property changes.
- RaiseChanged(MenuChangeKind)
Raises an event or performs an action to indicate that a change of the specified kind has occurred.
- RaiseCheckedChanged()
Raises the CheckedChanged event to notify subscribers of a checked state change.
- RaiseClick()
Calls RaiseClick(EventArgs) with an empty arguments.
- RaiseClick(EventArgs)
Raises the Click event and calls OnClick(EventArgs). See Click event description for more details.
- RaiseClickActionChanged()
Raises the ClickActionChanged event to notify subscribers of a change in the click action.
- RaiseClosed()
Raises Closed event.
- RaiseCommandSourceChanged()
Notifies that the state of the command source has changed.
- RaiseDisabledImageChanged()
Raises DisabledImageChanged event.
- RaiseEnabledChanged(EventArgs)
Raises the EnabledChanged event and calls OnEnabledChanged(EventArgs).
- RaiseHighlighted()
Raises Highlighted event.
- RaiseImageChanged()
Raises ImageChanged event.
- RaiseOpened()
Raises Opened event.
- RaiseRoleChanged()
Raises the RoleChanged event to notify subscribers of a role change.
- RaiseShortcutChanged()
Raises ShortcutChanged event.
- RaiseTextChanged(EventArgs)
Raises the TextChanged event.
- RaiseVisibleChanged(EventArgs)
Raises VisibleChanged event and OnVisibleChanged(EventArgs) method.
- SetEnabled(bool)
Same as Enabled but implemented as method.
- SetShortcutKeys(Keys)
Same as ShortcutKeys but implemented as method.
- SetText(string)
Sets the text content of the object. Same as setting Text property.
- SetVisible(bool)
Sets the visibility state of the object. Same as setting Visible property.
- ToString()
Returns a string that represents the current object.
- UpdateCommandState()
Updates the enabled state of the menu item based on the associated command. If there is no command associated, the method does not update enabled state. Additionally, it updates enabled state of child menu items if any.
Events
- Changed
Occurs when a change is detected, providing details about the type of change.
- CheckedChanged
Occurs when the Checked property changes.
- Click
Occurs when the menu item is clicked.
- ClickActionChanged
Occurs when the associated click action has changed.
- Closed
Occurs when menu item is closed.
- DisabledImageChanged
Occurs when the DisabledImage property changes.
- EnabledChanged
Occurs when the value of the Enabled property changes.
- Highlighted
Occurs when menu item is highlighted.
- ImageChanged
Occurs when the Image property changes.
- Opened
Occurs when menu item is opened.
- RoleChanged
Occurs when the Role property changes.
- ShortcutChanged
Occurs when the Shortcut property changes.
- TextChanged
Occurs when the Text property value changes.
- VisibleChanged
Occurs when the value of the Visible property changes.