更新 : 2007 年 11 月
メニュー項目のグループを表します。
名前空間 : Microsoft.Windows.Design.Interaction
アセンブリ : Microsoft.Windows.Design.Extensibility (Microsoft.Windows.Design.Extensibility.dll 内)
構文
'宣言
Public Class MenuGroup _
Inherits MenuBase
'使用
Dim instance As MenuGroup
public class MenuGroup : MenuBase
public ref class MenuGroup : public MenuBase
public class MenuGroup extends MenuBase
解説
メニュー項目は、MenuAction クラスによって表されます。メニュー グループには、メニューの直接のメニュー項目のコレクションか、フライアウト メニューとも呼ばれるサブメニューとしてのメニュー項目のコレクションを含めることができます。メニュー項目をサブメニューとして表示するには、HasDropDown プロパティを設定します。
コンテキスト メニュー項目を表示するには、PrimarySelectionContextMenuProvider クラスから継承し、MenuAction 項目および関連する MenuGroup を作成します。
例
2 つの MenuAction 項目をセットアップし、これらを MenuGroup に割り当てる方法を次のコード例に示します。詳細については、「チュートリアル : 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);
}
継承階層
System.Object
Microsoft.Windows.Design.Interaction.MenuBase
Microsoft.Windows.Design.Interaction.MenuGroup
スレッド セーフ
この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
参照
参照
Microsoft.Windows.Design.Interaction 名前空間
PrimarySelectionContextMenuProvider