EventManager.RegisterClassHandler 메서드

정의

특정 라우트된 이벤트에 대한 클래스 처리기를 등록합니다.

오버로드

RegisterClassHandler(Type, RoutedEvent, Delegate)

특정 라우트된 이벤트에 대한 클래스 처리기를 등록합니다.

RegisterClassHandler(Type, RoutedEvent, Delegate, Boolean)

특정 라우트된 이벤트에 대한 클래스 처리기를 등록하며, 이벤트 데이터가 이미 처리된 것으로 표시된 경우에도 이벤트를 처리할 수 있는 옵션이 있습니다.

RegisterClassHandler(Type, RoutedEvent, Delegate)

특정 라우트된 이벤트에 대한 클래스 처리기를 등록합니다.

public:
 static void RegisterClassHandler(Type ^ classType, System::Windows::RoutedEvent ^ routedEvent, Delegate ^ handler);
public static void RegisterClassHandler (Type classType, System.Windows.RoutedEvent routedEvent, Delegate handler);
static member RegisterClassHandler : Type * System.Windows.RoutedEvent * Delegate -> unit
Public Shared Sub RegisterClassHandler (classType As Type, routedEvent As RoutedEvent, handler As Delegate)

매개 변수

classType
Type

클래스 처리를 선언하는 클래스의 형식입니다.

routedEvent
RoutedEvent

처리할 이벤트의 라우트된 이벤트 식별자입니다.

handler
Delegate

클래스 처리기 구현에 대한 참조입니다.

예제

다음 예제에 대 한 처리기를 추가 PreviewMouseRightButtonDownEvent호출, RegisterClassHandler합니다.

static MyEditContainer()
{
  EventManager.RegisterClassHandler(typeof(MyEditContainer), PreviewMouseRightButtonDownEvent, new RoutedEventHandler(LocalOnMouseRightButtonDown));
}
internal static void LocalOnMouseRightButtonDown(object sender, RoutedEventArgs e)
{
  MessageBox.Show("this is invoked before the On* class handler on UIElement");
  //e.Handled = true; //uncommenting this would cause ONLY the subclass' class handler to respond
}
Shared Sub New()
  EventManager.RegisterClassHandler(GetType(MyEditContainer), PreviewMouseRightButtonDownEvent, New RoutedEventHandler(AddressOf LocalOnMouseRightButtonDown))
End Sub
Friend Shared Sub LocalOnMouseRightButtonDown(ByVal sender As Object, ByVal e As RoutedEventArgs)
  MessageBox.Show("this is invoked before the On* class handler on UIElement")
  'e.Handled = True //uncommenting this would cause ONLY the subclass' class handler to respond
End Sub

설명

클래스 처리는 라우트된 이벤트를 백업 하는 라우트된 이벤트를 사용 하 여 구현 되는 연결 된 이벤트를 포함 하 여 사용할 수 있는 기능입니다. 클래스 처리기 클래스의 모든 인스턴스에 대해 존재 하는 정적 처리기와 비슷합니다. 처리기가 정적, 클래스 처리기를 사용 하 여 직접 인스턴스 속성을 변경할 수 없습니다 하지만 인스턴스를 통해 액세스할 수 있습니다는 sender 매개 변수 및/또는 이벤트 데이터입니다.

클래스 처리기는 인스턴스 처리기 보다 먼저 호출 됩니다. 이벤트를 처리 됨으로 표시의 동작을 포함 하는 클래스 처리기를 구현할 수 있습니다. 따라서 클래스 처리 이벤트에 대 한 인스턴스 처리기가 처리 된 이벤트에 대해 특별히 인스턴스 처리기 등록 하지 않으면 호출 되지 않습니다.

대부분의 WPF 기본 요소 이벤트는 클래스 처리 가상 메서드를 제공합니다. 기본 클래스를 상속 하는 클래스에서 이러한 메서드를 재정의 하면 클래스 호출 하지 않고 처리를 구현할 수 있습니다 RegisterClassHandler 정적 생성자에서. 이러한 클래스 처리 메서드는 일반적으로 입력된 이벤트에 대 한 존재 및 이름이 "On"으로 시작 하 고 클래스에서 처리 되는 이벤트의 이름으로 끝납니다.

클래스 처리에 대 한 자세한 내용은 참조 하세요. 라우트된 이벤트 것으로 표시를 처리 및 클래스 처리합니다.

이 서명을 사용 하 여, 처리 되지 않은 이벤트에 대 한 응답에만 호출할 클래스 처리기를 등록 됩니다. 이벤트 인수를 사용 하 여 처리 표시 된 경우에 호출 하는 클래스 처리기를 등록할 수도 있습니다는 RegisterClassHandler(Type, RoutedEvent, Delegate, Boolean) 시그니처를 사용 하 여 handledEventsTootrue합니다.

적용 대상

RegisterClassHandler(Type, RoutedEvent, Delegate, Boolean)

특정 라우트된 이벤트에 대한 클래스 처리기를 등록하며, 이벤트 데이터가 이미 처리된 것으로 표시된 경우에도 이벤트를 처리할 수 있는 옵션이 있습니다.

public:
 static void RegisterClassHandler(Type ^ classType, System::Windows::RoutedEvent ^ routedEvent, Delegate ^ handler, bool handledEventsToo);
public static void RegisterClassHandler (Type classType, System.Windows.RoutedEvent routedEvent, Delegate handler, bool handledEventsToo);
static member RegisterClassHandler : Type * System.Windows.RoutedEvent * Delegate * bool -> unit
Public Shared Sub RegisterClassHandler (classType As Type, routedEvent As RoutedEvent, handler As Delegate, handledEventsToo As Boolean)

매개 변수

classType
Type

클래스 처리를 선언하는 클래스의 형식입니다.

routedEvent
RoutedEvent

처리할 이벤트의 라우트된 이벤트 식별자입니다.

handler
Delegate

클래스 처리기 구현에 대한 참조입니다.

handledEventsToo
Boolean

라우트된 이벤트의 인수가 처리된 것으로 표시된 경우에도 이 클래스 처리기를 호출하려면 true이고, 이벤트가 처리된 것으로 표시된 경우 처리기를 호출하지 않는 기본 동작을 유지하려면 false입니다.

설명

클래스 처리는 라우트된 이벤트를 백업 하는 라우트된 이벤트를 사용 하 여 구현 되는 연결 된 이벤트를 포함 하 여 사용할 수 있는 기능입니다. 클래스 처리기 클래스의 모든 인스턴스에 대해 존재 하는 정적 처리기와 비슷합니다. 처리기가 정적, 클래스 처리기를 사용 하 여 직접 인스턴스 속성을 변경할 수 없습니다 하지만 인스턴스를 통해 액세스할 수 있습니다는 sender 매개 변수 및/또는 이벤트 데이터입니다.

클래스 처리기는 인스턴스 처리기 보다 먼저 호출 됩니다. 이벤트를 처리 됨으로 표시의 동작을 포함 하는 클래스 처리기를 구현할 수 있습니다. 따라서 클래스 처리 이벤트에 대 한 인스턴스 처리기가 처리 된 이벤트에 대해 특별히 인스턴스 처리기 등록 하지 않으면 호출 되지 않습니다.

대부분의 WPF 기본 요소 이벤트는 클래스 처리 가상 메서드를 제공합니다. 기본 클래스를 상속 하는 클래스에서 이러한 메서드를 재정의 하면 클래스 호출 하지 않고 처리를 구현할 수 있습니다 RegisterClassHandler 정적 생성자에서. 이러한 클래스 처리 메서드는 일반적으로 입력된 이벤트에 대 한 존재 및 이름이 "On"으로 시작 하 고 클래스에서 처리 되는 이벤트의 이름으로 끝납니다.

클래스 처리에 대 한 자세한 내용은 참조 하세요. 라우트된 이벤트 것으로 표시를 처리 및 클래스 처리합니다.

이 서명을 사용 하 여, 클래스 처리기 등록할 수를 설정 하 여 처리 이벤트 시 호출할 handledEventsTootrue합니다. 일반적으로 알려진된 처리 문제가 마우스나 키보드 이벤트를 처리 하는 입력된 시스템 같은 해결 하려는 경우에이 작업을 수행 해야 있습니다.

적용 대상