Sorry, this doesn't work. It doesn't even compile due to syntax errors.Try replacing
myButton.Click += new Action(myButton_Click);withmyButton.Click += myButton_Click;ormyButton.Click += () => {Console.Write("foo");};
From what I can tell in the MSDN article, the constructor format of Action doesn't do what you're thinking it does. I'll gladly take some correction on that if I didn't search deep enough though.
That was my thought as well. Since you already made a GUI: How did you listen for the mouse? Did you add an own class for this or where did you put it?I would track the mouse position and whether or not it's been clicked in the Window class, and then if the position of the cursor is inside of myButton when a click is dispatched call myButton.OnClick().
Not Telling