MenuGroup.HasDropDown (Propiedad)

Actualización: noviembre 2007

Obtiene o establece un valor que indica si los elementos de menú de la colección Items se agregan a un submenú.

Espacio de nombres:  Microsoft.Windows.Design.Interaction
Ensamblado:  Microsoft.Windows.Design.Extensibility (en Microsoft.Windows.Design.Extensibility.dll)

Sintaxis

Public Property HasDropDown As Boolean

Dim instance As MenuGroup
Dim value As Boolean

value = instance.HasDropDown

instance.HasDropDown = value
public bool HasDropDown { get; set; }
public:
property bool HasDropDown {
    bool get ();
    void set (bool value);
}
public function get HasDropDown () : boolean
public function set HasDropDown (value : boolean)

Valor de propiedad

Tipo: System.Boolean

true si los elementos de menú de la colección de elementos se va a agregar a un submenú; false si los elementos de la colección se va a agregar directamente al menú actual, representado con un separador en cada extremo.

Comentarios

Si HasDropDown es igual a true, los elementos de menú de la colección de elementos se agregan a un submenú. Un elemento de menú que tiene la propiedad DisplayName establecida en MenuGroup se agrega al menú actual y los elementos de menú se agregan a un submenú. Si HasDropDown es igual a false, los elementos de menú de la colección se agregan directamente al menú actual, representado con un separador en ambos extremos. Por ejemplo, suponga que tiene un grupo de menús denominado Diseño, con los elementos de menú Alinear a la izquierda y Alinear a la derecha. Si HasDropDown es igual a true, al menú actual se agregará un menú Diseño con los elementos de submenú Alinear a la izquierda y Alinear a la derecha. Si HasDropDown es igual a false, Alinear a la izquierda y Alinear a la derecha se agregarán al menú actual con un separador antes de Alinear a la izquierda y un separador después de Alinear a la derecha.

Ejemplos

En el siguiente ejemplo de código se muestra cómo configurar dos elementos MenuAction y asignarlos a MenuGroup. Para habilitar el comportamiento del submenú, la propiedad HasDropDown se establece en true. Para obtener más información, consulte Tutorial: Crear MenuAction.

' The provider's constructor sets up the MenuAction objects 
' and the the MenuGroup which holds them.
Public Sub New()

    ' Set up the MenuAction which sets the control's 
    ' background to Blue.
    setBackgroundToBlueMenuAction = New MenuAction("Blue")
    setBackgroundToBlueMenuAction.Checkable = True
    AddHandler setBackgroundToBlueMenuAction.Execute, AddressOf SetBackgroundToBlue_Execute

    ' Set up the MenuAction which sets the control's 
    ' background to its default value.
    clearBackgroundMenuAction = New MenuAction("Cleared")
    clearBackgroundMenuAction.Checkable = True
    AddHandler clearBackgroundMenuAction.Execute, AddressOf ClearBackground_Execute

    ' Set up the MenuGroup which holds the MenuAction items.
    Dim backgroundFlyoutGroup As New MenuGroup("SetBackgroundsGroup", "Set Background")

    ' If HasDropDown is false, the group appears inline, 
    ' instead of as a flyout. Set to true.
    backgroundFlyoutGroup.HasDropDown = True
    backgroundFlyoutGroup.Items.Add(setBackgroundToBlueMenuAction)
    backgroundFlyoutGroup.Items.Add(clearBackgroundMenuAction)
    Me.Items.Add(backgroundFlyoutGroup)

    ' The UpdateItemStatus event is raised immediately before 
    ' this provider shows its tabs, which provides the opportunity 
    ' to set states.
    AddHandler UpdateItemStatus, AddressOf CustomContextMenuProvider_UpdateItemStatus

End Sub
// The provider's constructor sets up the MenuAction objects 
// and the the MenuGroup which holds them.
public CustomContextMenuProvider()
{   
    // Set up the MenuAction which sets the control's 
    // background to Blue.
    setBackgroundToBlueMenuAction = new MenuAction("Blue");
    setBackgroundToBlueMenuAction.Checkable = true;
    setBackgroundToBlueMenuAction.Execute += 
        new EventHandler<MenuActionEventArgs>(SetBackgroundToBlue_Execute);

    // Set up the MenuAction which sets the control's 
    // background to its default value.
    clearBackgroundMenuAction = new MenuAction("Cleared");
    clearBackgroundMenuAction.Checkable = true;
    clearBackgroundMenuAction.Execute += 
        new EventHandler<MenuActionEventArgs>(ClearBackground_Execute);

    // Set up the MenuGroup which holds the MenuAction items.
    MenuGroup backgroundFlyoutGroup = 
        new MenuGroup("SetBackgroundsGroup", "Set Background");

    // If HasDropDown is false, the group appears inline, 
    // instead of as a flyout. Set to true.
    backgroundFlyoutGroup.HasDropDown = true;
    backgroundFlyoutGroup.Items.Add(setBackgroundToBlueMenuAction);
    backgroundFlyoutGroup.Items.Add(clearBackgroundMenuAction);
    this.Items.Add(backgroundFlyoutGroup);

    // The UpdateItemStatus event is raised immediately before 
    // this provider shows its tabs, which provides the opportunity 
    // to set states.
    UpdateItemStatus += 
        new EventHandler<MenuActionEventArgs>(
            CustomContextMenuProvider_UpdateItemStatus);
}

Permisos

Vea también

Referencia

MenuGroup (Clase)

MenuGroup (Miembros)

Microsoft.Windows.Design.Interaction (Espacio de nombres)

MenuAction

PrimarySelectionContextMenuProvider

Otros recursos

Tutorial: Crear MenuAction