开发者

Reregistering a handler for an event, with inheritance (add additional behavior to a handler from a base class)

If I inherit from a base class that handles some event like LeftMouseDownButton, and I rere开发者_开发知识库gister another handler for the same event, would both handlers be invoked (if I set e.Handled=false). So I want both the behavior of the handler of the base class and my handler to be invoked? That is I want to add some additional behavior to the base handler


Your would be better to avoid having multiple handlers invoked.

If you have access to the source code of the base class then you can make the handler a virtual method and then override it in the derived class. Have the derived class call the base class so you have the base class functionality execute and then tag on your extra actions afterwards. If you do not have access to the source code of the base class then I guess you are stuck having to add an additional handler and it is likely the base class handler will be invoked before your own handler because it will have been registered first.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜