Share via


MenuAction.Execute Event

Occurs when the menu item is executed.

Namespace:  Microsoft.Windows.Design.Interaction
Assembly:  Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)

Syntax

'Declaration
Public Event Execute As EventHandler(Of MenuActionEventArgs)
'Usage
Dim instance As MenuAction 
Dim handler As EventHandler(Of MenuActionEventArgs)

AddHandler instance.Execute, handler
public event EventHandler<MenuActionEventArgs> Execute
public:
 event EventHandler<MenuActionEventArgs^>^ Execute {
    void add (EventHandler<MenuActionEventArgs^>^ value);
    void remove (EventHandler<MenuActionEventArgs^>^ value);
}
JScript does not support events.

Remarks

Implement the logic for your MenuAction in the Execute event handler. This usually involves changing the state of the ModelItem that represents the selected control.

Examples

The following code example shows how to handle the Execute event. It sets the selected control's Background property to its default value. For more information, see Walkthrough: Creating a MenuAction.

' 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(Control.BackgroundProperty).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[Control.BackgroundProperty].ClearValue();
}

.NET Framework Security

See Also

Reference

MenuAction Class

MenuAction Members

Microsoft.Windows.Design.Interaction Namespace

PrimarySelectionContextMenuProvider

MenuGroup

ModelItem

Other Resources

Walkthrough: Creating a MenuAction