UIElement.RemoveHandler(RoutedEvent, Delegate) 메서드

정의

지정된 라우트된 이벤트 처리기를 이 요소에서 제거합니다.

public:
 virtual void RemoveHandler(System::Windows::RoutedEvent ^ routedEvent, Delegate ^ handler);
public void RemoveHandler (System.Windows.RoutedEvent routedEvent, Delegate handler);
abstract member RemoveHandler : System.Windows.RoutedEvent * Delegate -> unit
override this.RemoveHandler : System.Windows.RoutedEvent * Delegate -> unit
Public Sub RemoveHandler (routedEvent As RoutedEvent, handler As Delegate)

매개 변수

routedEvent
RoutedEvent

처리기가 연결된 라우팅된 이벤트의 식별자입니다.

handler
Delegate

이 요소의 이벤트 처리기 컬렉션에서 제거할 특정 처리기 구현입니다.

구현

예제

다음 예제에서는 이벤트 래퍼 정의의 일부로 사용합니다 RemoveHandler .

public static readonly RoutedEvent TapEvent = EventManager.RegisterRoutedEvent(
    "Tap", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyButtonSimple));

// Provide CLR accessors for the event
public event RoutedEventHandler Tap
{
        add { AddHandler(TapEvent, value); } 
        remove { RemoveHandler(TapEvent, value); }
}
Public Shared ReadOnly TapEvent As RoutedEvent = EventManager.RegisterRoutedEvent("Tap", RoutingStrategy.Bubble, GetType(RoutedEventHandler), GetType(MyButtonSimple))

' Provide CLR accessors for the event
Public Custom Event Tap As RoutedEventHandler
    AddHandler(ByVal value As RoutedEventHandler)
        Me.AddHandler(TapEvent, value)
    End AddHandler

    RemoveHandler(ByVal value As RoutedEventHandler)
        Me.RemoveHandler(TapEvent, value)
    End RemoveHandler

    RaiseEvent(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Me.RaiseEvent(e)
    End RaiseEvent
End Event

설명

이 API를 사용하는 가장 일반적인 시나리오는 특히 CLR 수준에서 처리기에 대한 "제거" 논리를 구현할 때 사용자 지정 라우트된 이벤트와 연결된 CLR(공용 언어 런타임) "래퍼" 이벤트를 구현하는 경우입니다. 이 설명 섹션을 따르는 예제에서는 이 시나리오를 보여 줍니다.

메서드 호출에 대한 입력 매개 변수와 일치하는 조건에 등록된 처리기가 없으면 이 메서드를 호출해도 아무 효과가 없습니다.

조건과 일치하는 처리기가 둘 이상 연결되어 있으면 이벤트 처리기 저장소의 첫 번째 처리기만 제거됩니다. 이 동작은 연산자의 CLR 동작과 일치합니다 -= .

어느 쪽도 routedEvent handler 아닐 null수도 있습니다. 두 값을 제공 null 하려고 하면 예외가 발생합니다.

이 메서드는 handledEventsToo 처리기가 이미 처리된 이벤트를 처리할 수 있도록 하는 서명과 함께 AddHandler(RoutedEvent, Delegate, Boolean) 처음 추가된 경우 제공되는 매개 변수 정보를 무시합니다. 두 유형의 처리기가 모두 제거됩니다.

적용 대상

추가 정보