You can define a tooltip on a grid (or border), but it will show up only when the mouse hovers over space “occupied” by a grid item. Empty space will not generate the tooltip. E.g.
Collapse
<Grid ToolTip="Yo!">
<Rectangle Fill="Yellow" Width="50" Height="50" HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
The tooltip will show only when hovering over a small yellow rectangle in the middle, and not elsewhere in the grid. If you add
<Rectangle />
to the grid, it won’t help. The rectangle by default gets null fill
brush and sort of “does not count”. If you want to extend the tooltip on the whole grid, do this: Collapse
<Grid ToolTip="Yo!">
<Rectangle Fill="Transparent" />
... other items ...
</Grid>
This will ensure the tooltip is visible everywhere in the grid. However, if the grid is large, this looks somewhat weird. The tooltip appears once and does not follow the mouse. Thus, for large grids, it may be better to leave things as they are.
The same technique applies to a
StackPanel
and WrapPanel
. Only space actually covered by controls like Label
, Button
, or Rectangle
will have tooltip. Hovering over empty space will not yield a tooltip.
No comments:
Post a Comment