Menu for WPF | ComponentOne
Menu Overview / Flat Menu / Automatic Closing
In This Topic
    Automatic Closing
    In This Topic

    By default, the menu, its submenus, and the submenus of a C1Menu control remains open even when a user clicks outside of the menu. The only way users can close the menu is by clicking the C1Menu control. However, you can change this behavior by enabling the automatic closing feature, which will allow users to close menus by clicking outside of the menu control's boundaries. To turn on automatic closing, set the AutoClose property to True.

    To enable automatic closing, use one of the following methods:

    Complete the following steps:

    1. Add AutoClose="True" to the <c1:C1Menu> or the <c1:C1ContextMenu> tag.
    2. Run the program.

    Complete the following steps:

    1. In Source view, locate the <c1:C1MenuItem> tag for the item you wish to make checkable and add x:Name="C1Menu1" to it. This will give the item a unique identifier that you can use in code.
    2. Enter Code view and add the following code beneath the InitializeComponent() method:
    Visual Basic
    Copy Code
    C1Menu1.AutoClose = True
    

     

    C#
    Copy Code
    C1Menu1.AutoClose = true;
    
    1. Run the program.

    Complete the following steps:

    1. Select the C1Menu control.

    The control's properties will appear in the Properties window.

    1. Select the AutoClose check box.
    2. Run the program.