MenuGroup.HasDropDown 屬性
更新:2007 年 11 月
取得或設定值,這個值表示是否要將 Items 集合中的功能表項目加入至子功能表。
命名空間: Microsoft.Windows.Design.Interaction
組件: Microsoft.Windows.Design.Extensibility (在 Microsoft.Windows.Design.Extensibility.dll 中)
語法
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)
屬性值
如果會將項目集合中的功能表項目加入至子功能表,則為 true;如果直接將集合中的項目加入至目前的功能表,並且在每個項目兩端以分隔符號來呈現,則為 false。
備註
如果 HasDropDown 等於 true,則項目集合中的功能表項目都會加入至子功能表。其 DisplayName 屬性設定為 MenuGroup 的功能表項目會加入至目前的功能表,而這個功能表的功能表項目則會加入至子功能表。如果 HasDropDown 等於 false,則集合中的功能表項目都會直接加入至目前的功能表,並且在每個項目兩端以分隔符號來呈現。例如,假設有名為 [Layout] 的功能表群組,其功能表項目為 [Align Left] 和 [Align Right]。如果 HasDropDown 等於 true,則會將 [Layout] 功能表加入至目前的功能表,而其子功能表項目為 [Align Left] 和 [Align Right]。如果 HasDropDown 等於 false,則會將 [Align Left] 和 [Align Right] 加入至目前的功能表,並且 [Align Left] 之前和 [Align Right] 之後都各有一個分隔符號。
範例
在下列程式碼範例中,會說明如何設定兩個 MenuAction 項目,並將它們指派給 MenuGroup。HasDropDown 屬性會設定為 true 以啟用延伸式行為。如需詳細資訊,請參閱逐步解說:建立 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);
}
使用權限
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.Windows.Design.Interaction 命名空間
PrimarySelectionContextMenuProvider