|
-
Aug 29th, 2013, 02:32 PM
#1
Thread Starter
Hyperactive Member
Is there a way to tell where an event was raised from?
I've got an event that's firing more times than I thought it should fire. Is there any way to tell where an event was raised from?
The event is DataContextChanged for a ComboBox. All I need is basic data on what caused the event to fire... any way to do it?
-
Aug 29th, 2013, 03:16 PM
#2
Re: Is there a way to tell where an event was raised from?
Yes, the sender argument of all event handlers keeps a reference to the object that raised the event.
-
Aug 29th, 2013, 04:56 PM
#3
Thread Starter
Hyperactive Member
Re: Is there a way to tell where an event was raised from?
Yeah, I checked that first. They all point back to the combo box itself... and since I know for a fact that at least one of the events is fired via code, manually setting the SelectedIndex value... well, that means that it doesn't really differentiate between code and user action.
-
Aug 29th, 2013, 05:11 PM
#4
Re: Is there a way to tell where an event was raised from?
Could you not set a breakpoint on the event handler and, when hit, examine the call stack? I think that any code that is causing the event will show up that way.
-
Aug 29th, 2013, 05:12 PM
#5
Re: Is there a way to tell where an event was raised from?
You you've solved the problem I take it?
[EDIT]
Inferred posted while I was making mine.
My question was in response to your last post:-
Yeah, I checked that first. They all point back to the combo box itself... and since I know for a fact that at least one of the events is fired via code, manually setting the SelectedIndex value... well, that means that it doesn't really differentiate between code and user action.
I'm not certain what you are trying to say here.
-
Aug 29th, 2013, 05:14 PM
#6
Re: Is there a way to tell where an event was raised from?
There isn't necessarily a way to determine what caused the event to trigger, just who triggered it. Examining the call stack at the time of the event can tell you some things, but it may not tell you what you want to know. MSDN might also give you some information as to what actions can trigger certain events, but aside from that you can probably work it out just by testing things.
My usual boring signature: Nothing
 
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|