DependencyObject.RemoveHandler(DependencyProperty, Object) Method

Definition

Removes an EventHandler from an associated DependencyProperty.

C#
public void RemoveHandler(System.Workflow.ComponentModel.DependencyProperty dependencyEvent, object value);

Parameters

dependencyEvent
DependencyProperty

The DependencyProperty.

value
Object

The Object that represents the value of this property. In this case, a Delegate type.

Exceptions

Either of the arguments is a null reference (Nothing in Visual Basic).

The dependencyEvent is a metaproperty.

-or-

The dependencyEvent is not an event.

The value is a ActivityBind and this instance is not in DesignMode.

Examples

Handlers are added and removed using the following code. For more information, see Send Email Activity Sample.

C#
#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);
    }
}

Remarks

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. 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.

Applies to

Proizvod Verzije
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1