开发者

Class-level event handler in WPF

HEllo, can someone explain me what class-level event handler is in WPF? I use routed events in WPF but currently I read a book and I found the author mentions about class-level event handler. What is the practical use of this techn开发者_JAVA技巧ique?


Think of class handlers as static event handlers for a routed event. You might want to register such a handler if you want, for example, handle all mouse down events without any particular instance of the object involved. You would typically register it in a static constructor of a class:

static MyWindow()
{
    EventManager.RegisterClassHandler(typeof(MyWindow), PreviewMouseLeftButtonDownEvent, new RoutedEventHandler(OnMouseLeftButtonDown));
}

See also:

http://msdn.microsoft.com/en-us/library/ms597875.aspx

http://karlshifflett.wordpress.com/2008/04/22/wpf-sample-series-eventmanagerregisterclasshandler/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜