When adding an event handler to a control using the +=
syntax, how are the sender
and RoutedEventArgs
created under the hood? What are their default values?
Also, is there a scenario where I’d need to instantiate my own RoutedEventArgs
? If yes, how would I then “pass” it using the +=
syntax? Should I use a different syntax to attach the handler?
The goal of this question is to gain understanding of the WPF/Avalonia event handling mechanism. I don’t have a specific use-case in mind.
Thanks
2
I found my answer by looking at the code of the OnClick
method of the Avalonia.Controls.Button
class.
So it’s the Control raising the event that instantiates the RoutedEventArgs
.
I can’t be 100% sure that this is the only scenario where the RoutedEventArgs
is instantiated though.
1