MenuGroup.HasDropDown 属性
获取或设置一个值,该值表示 Items 中的菜单项是否可以添加下级菜单。
命名空间: Microsoft.Windows.Design.Interaction
程序集: Microsoft.Windows.Design.Interaction(在 Microsoft.Windows.Design.Interaction.dll 中)
语法
声明
Public Property HasDropDown As Boolean
Get
Set
public bool HasDropDown { get; set; }
public:
property bool HasDropDown {
bool get ();
void set (bool value);
}
member HasDropDown : bool with get, set
function get HasDropDown () : boolean
function set HasDropDown (value : boolean)
属性值
类型:System.Boolean
如果项集合中的菜单项将被添加到子菜单,则为 true;如果集合中的项将直接被添加到当前菜单,并将在各端用分隔符呈现出来,则为 false。
备注
如果 HasDropDown 等于 true,在项集合中的菜单项将添加到一个子菜单。 其 DisplayName 属性设置为 MenuGroup 的菜单项被添加到当前菜单,其他菜单项被添加到子菜单。 如果 HasDropDown 等于 false,则集合中的菜单项会直接添加到当前菜单中,且两端都呈现分隔符。 例如,考虑菜单组中的 **“布局”**以及菜单项中 “左对齐” 和 “右对齐”。 如果 HasDropDown 等于 true,一个 布局 菜单将添加到当前的菜单中,带有 左对齐 和 右对齐 的子菜单项。 如果 HasDropDown 等于 false,左对齐 和 右对齐 将添加到 左对齐 前会显示分隔符的和 右对齐 后会显示分隔符的当前菜单中。
示例
以下代码示例演示如何设置两个 MenuAction 项并将其赋给一个 MenuGroup。 HasDropDown 属性被设置为 true 来启用飞出行为。 有关更多信息,请参见 演练:创建菜单提供程序。
' 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);
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.Windows.Design.Interaction 命名空间
PrimarySelectionContextMenuProvider