Menu bars are represented by the NMenuBar class, that derives from NCommandBar. Menu Bars are not additing any new functionality to Command Bars, but are often used as a type target in styling to distingush them. The FillLane and Wrappable properties for menu bars are by default set true.
As menu bars are command bars you can place any type of widget inside them. In most cases however you will populate menu bars with menu drop downs, like shown in the following image:
figure 1. Menu Bar with Menu Drop Downs.
The menu bar shown above was be created with the following code:
Menu Bar Example |
Copy Code
|
---|---|
NMenuBar menuBar = new NMenuBar(); NMenuDropDown fileMenu = new NMenuDropDown("File"); menuBar.Items.Add(fileMenu); NMenuItem newMenuItem = new NMenuItem("New"); fileMenu.Items.Add(newMenuItem); newMenuItem.Items.Add(new NMenuItem("Project")); newMenuItem.Items.Add(new NMenuItem("Web Site")); newMenuItem.Items.Add(new NMenuItem("File")); NImage fileOpenImage = new NImage(new NUri(@"C:\FileOpen.png")); fileMenu.Items.Add(new NMenuItem(fileOpenImage, "Open")); fileMenu.Items.Add(new NMenuItem("Save")); fileMenu.Items.Add(new NMenuItem("Save As...")); fileMenu.Items.Add(new NMenuSeparator()); fileMenu.Items.Add(new NMenuItem("Exit")); NMenuDropDown editMenu = new NMenuDropDown("Edit"); menuBar.Items.Add(editMenu); editMenu.Items.Add(new NMenuItem("Undo")); editMenu.Items.Add(new NMenuItem("Redo")); editMenu.Items.Add(new NMenuSeparator()); editMenu.Items.Add(new NMenuItem("Cut")); editMenu.Items.Add(new NMenuItem("Copy")); editMenu.Items.Add(new NMenuItem("Paste")); |