Menu Class

Represents a Windows menu control that enables you to hierarchically organize elements associated with commands and event handlers.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:

public class Menu : MenuBase
public class Menu extends MenuBase
public class Menu extends MenuBase

Content Model: Menu is an ItemsControl. For more information on the content model for Menu, see ItemsControl Content Model.

The Menu control presents a list of items that specify commands or options for an application. Typically, clicking an item on a menu opens a submenu or causes an application to carry out a command.

An item in a menu can be anything that can be added to an ItemCollection. The MenuItem is the most common type of item in a Menu. A MenuItem can contain child items. The child items will appear in a submenu when the user chooses a parent MenuItem.

This example shows how to create Menu controls. The example illustrates Menu controls with submenus and MenuItem elements with ToolTip controls. The example also shows how to use the IsCheckable property to make MenuItem controls that can be checked.

<Menu Width="30" Margin="10, 10, 5, 5" HorizontalAlignment="Left" Background="White">
   <MenuItem Header="_File">
          <MenuItem Header="_New" IsCheckable="true"/>
          <MenuItem Header="_Open" IsCheckable="true"/>
          <MenuItem Header="_Close" IsCheckable="true"/>
          <MenuItem Header="Menu with Submenu">
                <MenuItem Header="_submenuitem1" IsCheckable="true"/>
                <MenuItem Header="_submenuitem2" IsCheckable="true">          
                    <MenuItem Header="_submenuitem2.1" IsCheckable="true"/>
         <MenuItem Header="_Menu item with ToolTip">
            ToolTip Information.

menu = new Menu();
menu.Background = Brushes.LightBlue;
mi = new MenuItem();
mi.Width = 50;
mi.Header = "_File";

mia = new MenuItem();
mia.Header = "_Cut";
mia.InputGestureText = "Ctrl+X";

mib = new MenuItem();
mib.Command = System.Windows.Input.ApplicationCommands.Copy;
mib.Header = "_Copy";

mic = new MenuItem();
mic.Command = System.Windows.Input.ApplicationCommands.Paste;
mic.Header = "_Paste";

For the complete sample, see Menu Sample.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions