MenuAction.Execute Event

Occurs when the menu item is executed.

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

Syntax

'Declaration
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 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 Menu Provider.

' 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 Security

See Also

Reference

MenuAction Class

Microsoft.Windows.Design.Interaction Namespace

PrimarySelectionContextMenuProvider

MenuGroup

ModelItem

Other Resources

Walkthrough: Creating a Menu Provider