Skip to main content

Microsoft Silverlight

Answered Question Possible to get Canvas metadata at mouse position?RSS Feed

(0)

jlermanvt
jlermanvt

Member

Member

16 points

7 Posts

Possible to get Canvas metadata at mouse position?

I would like to respond to a mouse click event and get some information (more than x and y values) about the mouse position. Specifically, I would like to find out the color of the object (which is filled with a gradient brush) at a particular point. I have not been able to figure this out. Is it even possible?

WynApse
WynApse

Star

Star

8456 points

342 Posts

Silverlight MVP
Answered Question

Re: Possible to get Canvas metadata at mouse position?

We don't have hit-testing as such, but if one of your objects caused the event, you can get information about that object.

ZIndex comes into play, and Opacity 0 objects that are not hidden will sneak up and bite you when you don't expect it.

I use the mouse event to get a name, append some text to the name, and go get another objects information that I then use in my menu.

If, however, your mouse event is on the canvas and it contains a whole bunch of objects, then you're probably out of luck...

-Dave

Stay in the 'Light
Silverlight MVP
http://www.wynapse.com
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities