共用方式為


MenuAction.Execute 事件

在執行功能表項目時發生。

命名空間:  Microsoft.Windows.Design.Interaction
組件:  Microsoft.Windows.Design.Interaction (在 Microsoft.Windows.Design.Interaction.dll 中)

語法

'宣告
Public Event Execute As EventHandler(Of MenuActionEventArgs)
public event EventHandler<MenuActionEventArgs> Execute
public:
 event EventHandler<MenuActionEventArgs^>^ Execute {
    void add (EventHandler<MenuActionEventArgs^>^ value);
    void remove (EventHandler<MenuActionEventArgs^>^ value);
}
member Execute : IEvent<EventHandler<MenuActionEventArgs>,
    MenuActionEventArgs>
JScript 不支援事件。

備註

您可以在 Execute 事件處理常式中實作 MenuAction 的邏輯。 這通常涉及變更代表所選取控制項之 ModelItem 的狀態。

範例

下列程式碼範例示範如何處理 Execute 事件。 它會將所選取之控制項的 Background 屬性設定為其預設值。 如需詳細資訊,請參閱逐步解說:建立功能表提供者

' The following method handles the Execute event. 
' It sets the Background property to its default value.
Sub ClearBackground_Execute( _
    ByVal sender As Object, _
    ByVal e As MenuActionEventArgs)

    Dim selectedControl As ModelItem = e.Selection.PrimarySelection
    selectedControl.Properties("Background").ClearValue()

End Sub
// The following method handles the Execute event. 
// It sets the Background property to its default value.
void ClearBackground_Execute(
    object sender, 
    MenuActionEventArgs e)
{
    ModelItem selectedControl = e.Selection.PrimarySelection;
    selectedControl.Properties["Background"].ClearValue();
}

.NET Framework 安全性

請參閱

參考

MenuAction 類別

Microsoft.Windows.Design.Interaction 命名空間

PrimarySelectionContextMenuProvider

MenuGroup

ModelItem

其他資源

逐步解說:建立功能表提供者