Class MenuBar
Provides a menu bar that spans the top of a Toplevel View with drop-down and cascading menus.
By default, any sub-sub-menus (sub-menus of the MenuItems added to MenuBarItems) are displayed in a cascading manner, where each sub-sub-menu pops out of the sub-menu frame (either to the right or left, depending on where the sub-menu is relative to the edge of the screen). By setting UseSubMenusSingleFrame to true, this behavior can be changed such that all sub-sub-menus are drawn within a single frame below the MenuBar.
public class MenuBar : View, IDisposable, ISupportInitializeNotification, ISupportInitialize, IDesignable
- Inheritance
-
MenuBar
- Implements
- Inherited Members
Remarks
The MenuBar appears on the first row of the Toplevel SuperView and uses the full width.
See also: ContextMenu
The MenuBar provides global hot keys for the application. See HotKey.
When the menu is created key bindings for each menu item and its sub-menu items are added for each menu item's hot key (both alone AND with AltMask) and shortcut, if defined.
If a key press matches any of the menu item's hot keys or shortcuts, the menu item's action is invoked or sub-menu opened.
* If the menu bar is not open * Any shortcut defined within the menu will be invoked * Only hot keys defined for the menu bar items will be invoked, and only if Alt is pressed too. * If the menu bar is open * Un-shifted hot keys defined for the menu bar items will be invoked, only if the menu they belong to is open (the menu bar item's text is visible). * Alt-shifted hot keys defined for the menu bar items will be invoked, only if the menu they belong to is open (the menu bar item's text is visible). * If there is a visible hot key that duplicates a shortcut (e.g. _File and Alt-F), the hot key wins.
Constructors
Properties
- HotKeySpecifier
The specifier character for the hot keys.
- LastFocused
Gets the view that was last focused before opening the menu.
- Menus
Gets or sets the array of MenuBarItems for the menu. Only set this after the MenuBar is visible.
- MenusBorderStyle
The default LineStyle for Menus's border. The default is Single.
- UseKeysUpDownAsKeysLeftRight
Used for change the navigation key style.
- UseSubMenusSingleFrame
Gets or sets if the sub-menus must be displayed in a single or multiple frames.
By default, any sub-sub-menus (sub-menus of the main MenuItems) are displayed in a cascading manner, where each sub-sub-menu pops out of the sub-menu frame (either to the right or left, depending on where the sub-menu is relative to the edge of the screen). By setting UseSubMenusSingleFrame to true, this behavior can be changed such that all sub-sub-menus are drawn within a single frame below the MenuBar.
Methods
- CloseMenu(bool)
Closes the Menu programmatically if open and not canceled (as though F9 were pressed).
- EnableForDesign<TContext>(ref readonly TContext)
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.
- OnDrawingContent()
Called when the View's content is to be drawn. The default implementation does nothing.
- OnMenuAllClosed()
Virtual method that will invoke the MenuAllClosed.
- OnMenuClosing(MenuBarItem, bool, bool)
Virtual method that will invoke the MenuClosing.
- OnMenuOpened()
Virtual method that will invoke the MenuOpened event if it's defined.
- OnMenuOpening(MenuBarItem)
Virtual method that will invoke the MenuOpening event if it's defined.
- OnMouseEvent(MouseEventArgs)
Called when a mouse event occurs within the view's Viewport.
- OpenMenu()
Opens the Menu programatically, as though the F9 key were pressed.
- PositionCursor()
Positions the cursor in the right position based on the currently focused view in the chain.
Events
- MenuAllClosed
Raised when all the menu is closed.
- MenuClosing
Raised when a menu is closing passing MenuClosingEventArgs.
- MenuOpened
Raised when a menu is opened.
- MenuOpening
Raised as a menu is opening.