RoutedEventArgs.Source vs Sender

前端 未结 4 1063
执念已碎
执念已碎 2020-12-05 11:44

What is the difference between sender and source in wpf event handling?

For example, say I had an ellipse in a canvas, and clicked on the ellipse:

4条回答
  •  伪装坚强ぢ
    2020-12-05 12:38

    Sender: Current element that is handling the event

    OriginalSource: original object that first raised the event

    Source: object that raised event. This is usually the same as OriginalSource but when dealing with Composite Controls it can be the parent that contains the OriginalSource object.*

    RoutedEvent: Provides the RoutedEvent object for the event triggered by your event handler (such as the static UIElement.MouseUpEvent object). This information is useful if you’re handling different events with the same event handler.

    Handled: Allows you to halt the event bubbling or tunneling process. When a control sets the Handled property to true, the event doesn’t travel any further and isn’t raised for any other elements.

提交回复
热议问题