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 类型。

例外

自变量之一为空引用(在 Visual Basic 中为 Nothing)。

dependencyEventmetaproperty

  • 或 -

dependencyEvent 不是事件。

valueActivityBind,但此实例不处于 DesignMode

示例

使用下面的代码添加和移除处理程序。 有关详细信息,请参阅 “发送电子邮件活动示例”。

#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

注解

作为用于移除事件委托的方便而直接的方法提供。

创建委托时,请标识将要处理事件的方法。 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。 除非移除了该委托,否则每当发生该事件时都会调用事件处理程序。 有关事件处理程序委托的详细信息,请参阅 处理和引发事件

适用于