Classe MenuGroup
Representa um agrupar de itens de menu.
Namespace: Microsoft.Windows.Design.Interaction
Assembly: Microsoft.Windows.Design.Extensibility (em Microsoft.Windows.Design.Extensibility.dll)
Sintaxe
Public Class MenuGroup _
Inherits MenuBase
Dim instance As MenuGroup
public class MenuGroup : MenuBase
public ref class MenuGroup : public MenuBase
public class MenuGroup extends MenuBase
Comentários
Itens de menu são representados pelo MenuAction classe. Um agrupar de menu pode ter uma coleção de itens de menu diretamente no menu ou sistema autônomo um submenu, que também é chamado de um submenu menu.conjunto o HasDropDown propriedade para exibir itens de menu em um submenu.
Para mostrar itens de menu de contexto, herdam o PrimarySelectionContextMenuProvider classe e criar MenuAction itens e um associado MenuGroup.
Exemplos
O exemplo de código a seguir mostra como configurar dois MenuAction itens e atribuí-los para um MenuGroup. Para obter mais informações, consulte Demonstra Passo a passo: Criando um 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);
}
Hierarquia de herança
System.Object
Microsoft.Windows.Design.Interaction.MenuBase
Microsoft.Windows.Design.Interaction.MenuGroup
Acesso thread-safe
Quaisquer membros static (Shared no Visual Basic) públicos deste tipo são thread-safe. Não há garantia de que qualquer membro de instância seja thread-safe.
Consulte também
Referência
Namespace Microsoft.Windows.Design.Interaction
PrimarySelectionContextMenuProvider