Who Ate My Mouse Down Event??

Before I leave, I want to squeeze in one quick note about a problem a lot of folks are running into as they upgrade from Beta 1 to Beta 2. I’ll come back to this in more detail when I get back, but here it is in a nutshell.

A breaking change in the Beta 2 upgrade is that all the controls now handle MouseLeftButtonDown/Up/Move, while graphic objects do not.

That means that no built in control will pass those events on (bubble them up) anymore. So, if you revisit my example for drag and drop what you’ll find is that if you create a button that has a graphic object inside it, and you drag on the button, it will not move, but if you drag on the graphic object it will! 

VLGMButton

You can see this in (the newly updated) Tutorial #1 (where the image for Drag and Drop is misleading). Dragging on the Very Little Green Man works, dragging on the button he is in, does not.

That is because the Very Little Green Man consists of nothing but Graphics (elipses and paths) but the button is a control and the control eats the event.

This is why figure 1.9 in the tutorial has to be replaced; you can’t drag the button, you have to drag the green man,

BrokenImage
Broken image

It’s subtle but important, where the mouse is shown, you could not be dragging. Yes, in Beta 1, no in Beta 2.

FixedImage
Fixed image

Here the mouse is dragging the little green man, and that will work just fine.

The full reason for this is to come, but the short explanation is that this helps controls in Silverlight behave more like controls in WPF.

About Jesse Liberty

Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen Pluralsight & LinkedIn Learning courses. He was a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a Xamarin Certified Mobile Developer and a Xamarin MVP and a Microsoft MVP.
This entry was posted in z Silverlight Archives. Bookmark the permalink.