Remarque
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de vous connecter ou de modifier des répertoires.
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de modifier des répertoires.
Mise à jour : novembre 2007
Obtient ou définit une valeur qui indique si les éléments de menu dans la collection Items sont ajoutés à un sous-menu.
Espace de noms : Microsoft.Windows.Design.Interaction
Assembly : Microsoft.Windows.Design.Extensibility (dans Microsoft.Windows.Design.Extensibility.dll)
Syntaxe
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)
Valeur de propriété
Type : System.Boolean
true si les éléments de menu dans la collection d'éléments vont être ajoutés à un sous-menu ; false si les éléments dans la collection vont être ajoutés directement au menu actuel, avec un séparateur à chaque extrémité.
Notes
Si HasDropDown est true, les éléments de menu dans la collection d'éléments sont ajoutés à un sous-menu. Un élément de menu dont la propriété DisplayName a la valeur MenuGroup est ajouté au menu actuel et les éléments de menu sont ajoutés à un sous-menu. Si HasDropDown est false, les éléments de menu dans la collection sont ajoutés directement au menu actuel, avec un séparateur aux deux extrémités. Prenons par exemple un groupe de menus nommé Mise en page, avec des éléments de menu Aligner à gauche et Aligner à droite. Si HasDropDown est true, un menu Mise en page est ajouté au menu actuel avec les éléments Aligner à gauche et Aligner à droite dans le sous-menu. Si HasDropDown est false, Aligner à gauche et Aligner à droite sont ajoutés au menu actuel avec un séparateur avant Aligner à gauche et un séparateur après Aligner à droite.
Exemples
L'exemple de code suivant indique comment configurer deux éléments MenuAction et les assigner à un MenuGroup. La propriété HasDropDown a la valeur true pour activer le comportement volant. Pour plus d'informations, consultez Procédure pas à pas : création d'un 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);
}
Autorisations
- Confiance totale accordée à l'appelant immédiat. Ce membre ne peut pas être utilisé par du code d'un niveau de confiance partiel. Pour plus d'informations, consultez Utilisation de bibliothèques à partir de code d'un niveau de confiance partiel.
Voir aussi
Référence
Microsoft.Windows.Design.Interaction, espace de noms
PrimarySelectionContextMenuProvider