Condividi tramite


Proprietà MenuGroup.HasDropDown

Aggiornamento: novembre 2007

Ottiene o imposta un valore che indica se le voci di menu nell'insieme Items vengono aggiunte a un sottomenu.

Spazio dei nomi:  Microsoft.Windows.Design.Interaction
Assembly:  Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)

Sintassi

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)

Valore proprietà

Tipo: System.Boolean

true se le voci di menu dell'insieme di elementi verranno aggiunte a un sottomenu; false se gli elementi dell'insieme verranno aggiunti direttamente al menu corrente, sottoposti a rendering con un separatore a ogni estremità.

Note

Se HasDropDown è uguale a true, le voci di menu dell'insieme di elementi vengono aggiunte a un sottomenu. Una voce di menu la cui proprietà DisplayName è impostata su MenuGroup viene aggiunta al menu corrente e le voci di menu vengono aggiunte a un sottomenu. Se HasDropDown è uguale a false, le voci di menu dell'insieme vengono aggiunte direttamente al menu corrente, sottoposte a rendering con un separatore a entrambe le estremità. Ad esempio, si supponga di disporre di un gruppo di menu denominato Layout, con le voci di menu Allinea a sinistra e Allinea a destra. Se HasDropDown è uguale a true, nel menu corrente verrà aggiunto un menu Layout con le voci di sottomenu Allinea a sinistra e Allinea a destra. Se HasDropDown è uguale a false, Allinea a sinistra e Allinea a destra verranno aggiunte al menu corrente con un separatore prima di Allinea a sinistra e un separatore dopo Allinea a destra.

Esempi

Nell'esempio di codice seguente viene illustrato come configurare due elementi MenuAction e assegnarli a un oggetto MenuGroup. La proprietà HasDropDown è impostata su true per attivare il comportamento del menu a comparsa. Per ulteriori informazioni, vedere Procedura dettagliata: creazione di una 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);
}

Autorizzazioni

Vedere anche

Riferimenti

MenuGroup Classe

Membri MenuGroup

Spazio dei nomi Microsoft.Windows.Design.Interaction

MenuAction

PrimarySelectionContextMenuProvider

Altre risorse

Procedura dettagliata: creazione di una MenuAction