LINQPad.Controls Event sender got null
// Winform
var button = new System.Windows.Forms.Button {
Text = "Copy",
Location = new Point(150, 100),
Size = new Size(100, 30)
};
button.Click += (sender, e) => {
//here can got button object
var buttonSender = (sender as System.Windows.Forms.Button);
};
// LINQPad.Controls
var button = new LINQPad.Controls.Button("Copy").Dump();
button.Click += (sender, e) => {
// this got null
var buttonSender = (sender as LINQPad.Controls.Button);
};
Why transform sender to LINQPad.Controls always got null
Comments
-
var button = new LINQPad.Controls.Button("Copy").Dump(); button.Click += (sender, e) => { var buttonSender = sender.GetType().Dump(); };LINQPad.Controls.Core.HtmlElement -
Good spot. This is not ideal behavior - LINQPad should supply the button as the sender, not the HtmlElement. Fixing it is a breaking change, though, so it might have to wait for LINQPad 9.
