In
XAML and WPF model, the Menu and the MenuItem classes represent a menu
and a menu item respectively. A Menu is a collection of menu items with
a command associated with each menu items. A
menu item may have children menu items called submenus. This article
discusses how to work with menus in XAML and WPF applications.
Creating a Menu as Design Time
The Menu tag in XAML creates a menu control.
The Name property defines the name of the menu and Height and Width represents the height and width of a menu control.
<Menu Name="menu1" Height="22" Width="200" />
To
position a menu control in a Window, the Margin, HorizontalAlignment
and VerticalAlignment properties may be used. The following code sets
horizontal, vertical alignments, margin, and background color of a menu
control.
<Menu Height="22" Name="menu1" Width="200" Margin="10, 10, 5, 5" HorizontalAlignment="Left" VerticalAlignment="Top" Background="Chocolate">
</Menu>