MenuActionEventArgs.Selection Property

Gets the current selection on the design surface.

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

Syntax

'Declaration
Public ReadOnly Property Selection As Selection
    Get
public Selection Selection { get; }
public:
property Selection^ Selection {
    Selection^ get ();
}
member Selection : Selection
function get Selection () : Selection

Property Value

Type: Microsoft.Windows.Design.Interaction.Selection
A Selection representing the currently 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

MenuActionEventArgs Class

Microsoft.Windows.Design.Interaction Namespace

PrimarySelectionContextMenuProvider

MenuAction

MenuGroup

ModelItem

Other Resources

Walkthrough: Creating a Menu Provider