共用方式為


DependencyObject.RemoveHandler(DependencyProperty, Object) 方法

定義

EventHandler 從相關聯的 DependencyProperty 移除。

public:
 void RemoveHandler(System::Workflow::ComponentModel::DependencyProperty ^ dependencyEvent, System::Object ^ value);
public void RemoveHandler (System.Workflow.ComponentModel.DependencyProperty dependencyEvent, object value);
member this.RemoveHandler : System.Workflow.ComponentModel.DependencyProperty * obj -> unit
Public Sub RemoveHandler (dependencyEvent As DependencyProperty, value As Object)

參數

value
Object

Object,表示這個屬性的值。 在此情況下,為 Delegate 型別。

例外狀況

其中一個引數是 null 參考 (Visual Basic 中為 Nothing)。

dependencyEventmetaproperty

-或-

dependencyEvent 不是事件。

valueActivityBind,這個執行個體不在 DesignMode 中。

範例

使用以下程式碼可加入與移除處理常式。 如需詳細資訊,請參閱傳送Email活動範例

#region Public Events

[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Description("The SendingEmail event is raised before an email is sent through SMTP.")]
[Category(EventsCategory)]
[Browsable(true)]
public event EventHandler SendingEmail
{
    add
    {
        base.AddHandler(SendEmailActivity.SendingEmailEvent, value);
    }
    remove
    {
        base.RemoveHandler(SendEmailActivity.SendingEmailEvent, value);
    }
}

#Region "Public Events"

        <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
        <Description("The SendingEmail event is raised before an email is sent through SMTP.")> _
        <Category(EventsCategory)> _
        <Browsable(True)> _
        Public Custom Event SendingEmail As EventHandler
            AddHandler(ByVal value As EventHandler)
                MyBase.AddHandler(SendEmailActivity.SendingEmailEvent, value)
            End AddHandler

            RemoveHandler(ByVal value As EventHandler)
                MyBase.RemoveHandler(SendEmailActivity.SendingEmailEvent, value)
            End RemoveHandler

            RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs)

            End RaiseEvent
        End Event

備註

提供做為方便的指示方法,以移除事件委派。

當您建立委派時,就可以識別即將處理此事件的方法。 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (Instance) 加入至事件。 除非移除委派,否則每次發生事件時都會呼叫事件處理常式。 如需事件處理常式委派的詳細資訊,請參閱 處理和引發事件

適用於