Class MenuItem
- Namespace
- Myra.Graphics2D.UI
- Assembly
- Myra.dll
Represents a single item in a menu that can have sub-items, an image, and an optional shortcut text.
public class MenuItem : BaseObject, INotifyAttachedPropertyChanged, IMenuItem, IItemWithId
- Inheritance
-
MenuItem
- Implements
- Inherited Members
Constructors
MenuItem()
Initializes a new instance of the MenuItem class with default values.
public MenuItem()
MenuItem(string)
Initializes a new instance of the MenuItem class with the specified id.
public MenuItem(string id)
Parameters
idstringThe unique identifier for this menu item.
MenuItem(string, string)
Initializes a new instance of the MenuItem class with the specified id and text.
public MenuItem(string id, string text)
Parameters
idstringThe unique identifier for this menu item.
textstringThe display text for this menu item.
MenuItem(string, string, Color?)
Initializes a new instance of the MenuItem class with the specified id, text, and color.
public MenuItem(string id, string text, Color? color)
Parameters
idstringThe unique identifier for this menu item.
textstringThe display text for this menu item.
colorColor?The color of the menu item text, or null to use the style default.
MenuItem(string, string, Color?, object)
Initializes a new instance of the MenuItem class with the specified id, text, color, and tag.
public MenuItem(string id, string text, Color? color, object tag)
Parameters
idstringThe unique identifier for this menu item.
textstringThe display text for this menu item.
colorColor?The color of the menu item text, or null to use the style default.
tagobjectArbitrary user data to associate with this menu item.
Properties
CanOpen
Gets a value indicating whether this menu item can be opened (has submenu items).
[Browsable(false)]
public bool CanOpen { get; }
Property Value
Color
Gets or sets the color of the menu item text.
public Color? Color { get; set; }
Property Value
- Color?
Enabled
Gets or sets a value indicating whether this menu item is enabled.
[Browsable(false)]
public bool Enabled { get; set; }
Property Value
Image
Gets or sets the image displayed next to the menu item text.
public IImage Image { get; set; }
Property Value
Index
Gets or sets the zero-based index of this menu item within its parent menu.
[Browsable(false)]
public int Index { get; set; }
Property Value
Items
Gets the collection of submenu items nested under this menu item.
[Browsable(false)]
public ObservableCollection<IMenuItem> Items { get; }
Property Value
Menu
Gets or sets the parent menu of this item.
[Browsable(false)]
public Menu Menu { get; set; }
Property Value
ShortcutColor
Gets or sets the color of the shortcut text.
public Color? ShortcutColor { get; set; }
Property Value
- Color?
ShortcutText
Gets or sets the text displayed as a keyboard shortcut hint next to the menu item.
public string ShortcutText { get; set; }
Property Value
Tag
Gets or sets arbitrary user data associated with this menu item.
[Browsable(false)]
public object Tag { get; set; }
Property Value
Text
Gets or sets the text displayed for this menu item. An ampersand (&) marks a mnemonic character.
public string Text { get; set; }
Property Value
UnderscoreChar
Gets the mnemonic character for this menu item (the character after the ampersand in Text).
[Browsable(false)]
public char? UnderscoreChar { get; }
Property Value
- char?
Methods
FireChanged()
Fires the Changed event to notify listeners that this item has changed.
protected void FireChanged()
FireSelected()
Raises the Selected event to indicate that this menu item has been selected.
public void FireSelected()
OnIdChanged()
Called when the Id property changes, and fires the Changed event.
protected override void OnIdChanged()
Events
Changed
Occurs when any property of this menu item changes.
public event MyraEventHandler Changed
Event Type
Selected
Occurs when this menu item is selected.
public event MyraEventHandler Selected