IsSubmenuOpen Property

MenuItem.IsSubmenuOpen Property


Gets or sets a value that indicates whether the submenu of the MenuItem is open.

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

public bool IsSubmenuOpen { get; set; }

Property Value

Type: System.Boolean

true if the submenu of the MenuItem is open; otherwise, false. The default is false.

When IsSubmenuOpen is set to true, mouse capture is set to the MenuItem and its subtree.

The following example shows how to open a submenu of a MenuItem. In this example, the MenuItem called fileMenu contains a MenuItem called recentFiles that has a submenu. When fileMenu is opened, the SubmenuOpened event is raised and the FileMenu_Opened event handler opens the submenu of recentFiles.

  <MenuItem Name="fileMenu"

    <MenuItem Name="recentFiles" 
              Header="Recent files">

      <MenuItem Header="file 1"

      <MenuItem Header="file 2"
    <MenuItem Name="closeMenu" 
              Header="Close all Files"/>
private void FileMenu_Opened(object sender, RoutedEventArgs e)
    if (sender == e.Source)
        recentFiles.IsSubmenuOpen = true;

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft