Class Menu
A vertically-oriented Bar that contains MenuItem items, supporting cascading sub-menus, selection tracking, and the IValue<TValue> pattern.
public class Menu : Bar, IDisposable, ISupportInitializeNotification, ISupportInitialize, IOrientation, IDesignable, IValue<MenuItem?>, IValue
- Inheritance
-
Menu
- Implements
- Derived
- Inherited Members
- Extension Methods
Remarks
Menu extends Bar with vertical orientation and specializes it for MenuItem items. It supports Line separators between items and uses the Schemes.Menu color scheme by default.
Selection Tracking: The SelectedMenuItem property tracks the currently focused MenuItem. The SelectedMenuItemChanged event fires when the selection changes. OnSelectedMenuItemChanged(MenuItem?) automatically hides peer SubMenus and shows the selected item's SubMenu with positioning relative to the parent Menu.
Command Propagation: Sets CommandsToBubbleUp to [Accept, Activate], enabling commands from MenuItem items to propagate up through the menu hierarchy (e.g., through PopoverMenu and back to a MenuBarItem). Overrides OnActivating(CommandEventArgs) to dispatch Activate to the focused MenuItem.
IValue Support: Implements IValue<TValue> where T is MenuItem.
The Value property is automatically set when a MenuItem is activated or
accepted, enabling callers to determine which item triggered the command.
Hierarchy Traversal: Use GetAllSubMenus() for depth-first traversal of the SubMenu hierarchy, and GetMenuItemsOfAllSubMenus(Func<MenuItem, bool>?) to collect all MenuItems across the hierarchy with an optional predicate filter.
See Shortcut Deep Dive for details on the Shortcut base class and command routing patterns.
See Menus Deep Dive for the full menu system architecture, class hierarchy, command routing, and usage examples.
Constructors
Properties
- DefaultBorderStyle
Gets or sets the default Border Style for Menus. The default is None.
- SelectedMenuItem
Gets the currently selected menu item. This is a helper that tracks Focused.
- SuperMenuItem
Gets or sets the menu item that opened this menu as a sub-menu.
Methods
- Dispose(bool)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- EnableForDesign()
Causes the View to enable design-time mode. This typically means that the view will load demo data and be configured to allow for design-time manipulation.
- GetAllSubMenus()
Gets all the submenus in this menu's hierarchy, including this menu.
- GetMenuItemsOfAllSubMenus(Func<MenuItem, bool>?)
Gets menu items in this menu's hierarchy, optionally filtered by
predicate.
- OnAccepting(CommandEventArgs)
Called when the user is accepting the state of the View and the Accept has been invoked. Set CommandEventArgs.Handled to true and return true to indicate the event was handled and processing should stop.
- OnActivating(CommandEventArgs)
Called when the user has performed an action (e.g. Activate) causing the View to change state or preparing it for interaction. Set CommandEventArgs.Handled to true and return true to indicate the event was handled and processing should stop.
- OnFocusedChanged(View?, View?)
Called when the focused view has changed.
- OnSelectedMenuItemChanged(MenuItem?)
Called when the selected menu item has changed. Handles hiding peer SubMenus and showing the selected item's SubMenu.
- OnSubViewAdded(View)
Called when a SubView has been added to this View.
- OnValueChanged(ValueChangedEventArgs<MenuItem?>)
Called when Value has changed.
- OnValueChanging(ValueChangingEventArgs<MenuItem?>)
Called when Value is changing.
Events
- SelectedMenuItemChanged
Raised when the selected menu item has changed.
- ValueChanged
Raised when Value has changed.
- ValueChangedUntyped
Raised when Value has changed, providing the value as an un-typed object.
- ValueChanging
Raised when Value is about to change. Set Handled to true to cancel the change.