I need to know that how to check any event handler already assigned ? (in QuickWatch)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m not sure if I understood the question correctly, but I will give it a shot:
How to check if any event handlers attached to an event
TestEvent:TestEventwill be null if no event handlers attached.If one handler attached (single-cast delegate)
_invocationList == 0:Paste the following to the QuickWatch expression string:
to find out what event handler is attached.
If more than one handler attached (multicast delegate)
_invocationList > 0:You need to look through
_invocationList, for example to check first attached method:To check other attached handlers: change index to 1, 2, etc or just expand each element of the
_invocationListarray.Alternatively to using
Nameproperty which is just a handler method name, you can usem_toStringfield which is method signature.In all the examples about replace
TestEventwith the name of your event.[Edit] Didn’t realize you are using WPF. WPF event system is much more complicated.
Let’s say you have a button and what to check if any handler is attached to
MouseLeftButtonDownevent:button1).UIElement. Or to get there quickly paste this((System.Windows.UIElement)(button1)).EventHandlersStoreto the expression input.EventHandlersStore._entries._mapStore.[MS.Utility....]_entry0,_entry1, …_entry_n. Each of those are all the events that the button has handlers assigned too.Value=>_listStore._entry0,_entry1… again. Those are all the handlers attached to this particular event.