Spatacoli

You Canot MouseLeftButtonDown if you have no Mouse

I’m in the middle of a fairly large scale code review and I wanted to stop and alert everyone to a common mistake I am seeing in a lot of code that I read. You should use the Click event in about 99.99% of the cases that most people are using the MouseLeftButtonDown event. The reason for this is that if you have no mouse, there is no left button, and if there is no left mouse button it cannot go down.

Imagine if I am a keyboard only user, I would tend to Tab my way though a web page to find the button or link I want to activate. I would then press either the Space Bar or the Enter key to activate it. In POSH any Hyperlink would fire using either of these methods. In Silverlight either of these two methods will activate the Click event, but it will not substitute in for a MouseLeftButtonDown event.

I think this stems from Silverlight 1 where the only way to detect a click was to listen for the MouseLeftButtonDown event, but those days are long behind us.

If your intention is to actually capture an actual mouse event, then use MouseLeftButtonDown. However, if your intention is to capture a Click, use the Click event.