共用方式為


MenuActionEventArgs.Selection 屬性

取得目前設計介面上的選取範圍。

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

語法

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

屬性值

型別:Microsoft.Windows.Design.Interaction.Selection
Selection ,表示目前所選取的控制項。

範例

下列程式碼範例示範如何處理 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 安全性

請參閱

參考

MenuActionEventArgs 類別

Microsoft.Windows.Design.Interaction 命名空間

PrimarySelectionContextMenuProvider

MenuAction

MenuGroup

ModelItem

其他資源

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