DependencyObject.RemoveHandler(DependencyProperty, Object) DependencyObject.RemoveHandler(DependencyProperty, Object) DependencyObject.RemoveHandler(DependencyProperty, Object) DependencyObject.RemoveHandler(DependencyProperty, Object) Method

定義

EventHandler 從相關聯的 DependencyProperty 移除。Removes an EventHandler from an associated 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 Object Object

Object,表示這個屬性的值。The Object that represents the value of this property. 在此情況下,為 Delegate 型別。In this case, a Delegate type.

例外狀況

其中一個引數是 null 參考 (Visual Basic 中為 Nothing)。Either of the arguments is a null reference (Nothing in Visual Basic).

dependencyEventmetapropertyThe dependencyEvent is a metaproperty.

-或--or-

dependencyEvent 不是事件。The dependencyEvent is not an event.

valueActivityBind,這個執行個體不在 DesignMode 中。The value is a ActivityBind and this instance is not in DesignMode.

範例

使用以下程式碼可加入與移除處理常式。Handlers are added and removed using the following code. 如需詳細資訊, 請參閱傳送電子郵件活動範例For more information, see Send Email Activity Sample.

#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


備註

提供做為方便的指示方法,以移除事件委派。Provided as a convenient direct method for removing an event delegate.

當您建立委派時,就可以識別即將處理此事件的方法。When you create a delegate, you identify the method that will handle the event. 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (Instance) 加入至事件。To associate the event with your event handler, add an instance of the delegate to the event. 除非移除委派,否則每次發生事件時都會呼叫事件處理常式。Unless you remove the delegate, the event handler is called whenever the event occurs. 如需事件處理常式委派的詳細資訊, 請參閱處理和引發事件For more information about event-handler delegates, see Handling and Raising Events.

適用於