Follow these steps to add menus to your WPF application:
- Open the MainWindow.xaml page, and replace the default Grid with a DockPanel. We will discuss more about this panel in the next chapter.
- Now add the Menu control inside the DockPanel. This will create the base to hold all the menu items.
- You can then add root-level menu items and sub-menu items in a hierarchical fashion, as shown in the following code snippet:
<DockPanel> <Menu> <MenuItem Header="File"> <MenuItem Header="New" /> <MenuItem Header="Open" /> <MenuItem Header="Save" /> <Separator /> <MenuItem Header="Exit" /> </MenuItem> <MenuItem Header="Edit"> <MenuItem Header="Undo" /> <MenuItem Header="Redo" /> </MenuItem> ...