0

Question says it all.

Related thought/question:

Is there a way to "bubble-up" events then change the original sender without "intercepting" the event?

Example implementation:

public class Wheel
{
     public EventHandler<WheelTurningEventArgs> Turning;
}

This is the one without the sender in the EventArgs:

public class WheelTurningEventArgs : EventArgs
{
      public int TotalTurnCount { get; set; }
}

... and this is the one with the sender in the EventArgs.

public class WheelTurningEventArgs : EventArgs
{
       public Wheel Wheel {get; set;} //include a reference to the wheel that invoked this event
       public int TotalTurnCount { get; set; }

}
Community
  • 1
  • 1
Ian
  • 5,625
  • 11
  • 57
  • 93
  • Why does your `EventArgs` class have public setters? Wouldn't it make more sense to make it immutable? – svick Oct 24 '11 at 14:36
  • Also, if you implement “bubbling up” as [in the answer you linked](http://stackoverflow.com/questions/217233/bubbling-up-events/217366#217366), it *will* preserve the original sender. – svick Oct 24 '11 at 14:39
  • @svick Sorry, I meant the other way around. – Ian Oct 24 '11 at 15:37

1 Answers1

0

If this is a routed event, the WheelTurningEventArgs should inherit from the RoutedEventArgs class which will have the original source as well as the sender.

Kell
  • 3,252
  • 20
  • 19