More Samples
Download Wijmo

Hierarchical Menus

Wijmo's hierarchical menus support all the options supported by flat menus, including openOnHover, isAnimated, and right-to-left layouts.

The menu bar above contains three Menu controls. Each one is bound to a hierarchical list of commands which is an array of objects where items may contain child items. For example, the File menu has a New option with three sub-items: Project, Site, and File.

The first two menus respond to the menu's itemClicked event, which is raised when the user clicks an item that does not contain child items.

The last menu, Format, uses a command object that contains two functions:

  • canExecuteCommand: function that gets invoked when the menu is about to be displayed and returns a value that specifies whether the command is valid for the current state of the app.
  • executeCommand: function that gets invoked then the user clicks an enabled option.

Both functions take a parameter that is defined by the menu option objects. The command property is often used in MVVM applications. It provides a convenient way to centralize menu handling (enabling and invoking commands).