Friday, 2 November 2007

Silverlight (Orcas) - Mouse Events Not Working?!

I know this sounds stupid, but I was having a problem with mouse events.

So what happened was I have another control on top of the one that has mouse events. The control on top has a canvas as big as the one underneath, but a transparent background. Well, "transparent" <> "not exists", it's like a piece of glass on top. I forgot.

So if you find your mouse events not working, check if there is a piece of transparent control on top of it!

3 comments:

  1. so how did you resolve it? did you have to restructure your entire xaml page to get the mouse events to work?

    ReplyDelete
  2. nevermind - I figured it out. just use the z-index element to re-order your tree so that you can bring the element you need forward for event handling. See the z-index stuff here: http://msdn2.microsoft.com/en-us/library/bb188573.aspx#WalkingtheObjectTree

    ReplyDelete
  3. Todd, I didn't see your reply yesterday. :)

    In my case my control should not e that big actually, i.e. I have a lot of transparent space that I don't need. Therefore I change the canvas size of my control.

    Thanks for the z-index information.

    ReplyDelete