views:

131

answers:

2

In a Silverlight 2 app, I am using Rectangles on a Canvas to draw a representation of data. I would like to have mouse clicks on the Rectangles be passed on to the control that owns the Canvas. I would also like to be able to show a tooltip with a summary of the data when the mouse is over a Rectangle.

So far I've only been able to achieve one item or the other. If I make the Rectangles have their IsHitTestVisible property = false, the tooltips don't work, but the owning control will receive the mouse clicks. If I set it to true, then tooltips do work, but the clicks don't get passed on.

Is there a way to have a Silverlight item be IsHitTestvisible = true, and pass on the mouse clicks?

A: 

Have Canvas pass a reference of itself to Rectangles when they're constructed. When a rectangle is clicked, call a method on Canvas.

Edit: If Rectangles and Canvas are library classes, subclass them to add functionality you need.

A: 

I'm not sure why the tooltip and mouse left down / up is being linked, In SL3 the mouse left down / up will bubble unless it gets marked as handled by a routine / object. It sounds more like the event is not bubbling thru the parent controls. AFAIK SL2 does the same. (could be wrong on that one)

What is the visual tree from the outer parent to the inner rectangle?

Andrew