tags:

views:

1267

answers:

3

Hi, I have a canvas with user controls arranged on it. When a tooltip is assigned to the usercontrol or one of its children, that tooltip does not show (open event does not get fired either). I do not explicitly disable any of them.

I've placed plenty of tooltips elsewhere in the application and they all show, except the ones on the usercontrol I created.

Any ideas?

Hierarchy is roughly as follow:

<Grid>
 <Canvas>
  <UserControl>
   <Canvas>
    <Line/>
    <Rectangle/>
   </Canvas>
  </UserControl>
 </Canvas
</Grid>
A: 

If the background of the Usercontrol is x:Null, then the mouse events will fall through to the underlying content. You can use "Transparent" to ensure mouse events go to the usercontrol.

This behaviour isn't unique to usercontrols; it's the general behaviour for all of WPF. In your example, assuming you have a fill on child elements, you should be able to hover over those, and see the tooltips you have set.

dhopton
A: 

Hi yes, I had this problem originally when I tested in my root canvas, my rectangle was not showing a tooltip when the background was null. However, this is not resolving the issue for the user control. I tried a transparent background for both the user control and the canvas inside it, the rectangle inside that inner canvas has a black background and yet, no luck: the tooltip just won't open.

I did try to place a tooltip on my root canvas and it indeed shows up but not on my individual child user controls nor their inner canvas/children, even though they have a background/fill set.

Also, placing a MouseEnter event shows that it indeed fires when the mouse enters the inner canvas, yet, the tooltip will not pop.

A: 

Hi, I finally figured it out. On my canvas, I was drawing pointer lines (horizontal and vertical to show on the grid where I am and the values on the left/bottom), it turns out that when the hit test was being performed, it was hitting those lines and stopping. By setting IsHitTestVisible to false on all unrelevant geometry, my tooltip now shows properly.

The reason I was seeing the mouse enter/leave event was because when moving the cursor, the lines would drag 1 frame behind and thus allow the mouse to enter/leave but not move.

This resolves my issue.