Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!

Over the past year Corey was a lead developer on the NBCOlympics.com Silverlight 2 video player, he is currently finishing up a book with PeachPit Press - Microsoft Expression Blend a Visual Quickstart Guide (ISBN 0-321-41223-0), and he maintains a Silverlight blog “Silverlight made Simple”. Other Silverilght project he has worked on are HSN.tv with Silverlight 1.0 and the Blockbuster Stream application using Silverlight 2. Corey is a DZone MVB and is not an employee of DZone and has posted 14 posts at DZone. You can read more from them at their website. View Full User Profile

Silverlight ToolTips – Positioning and Customizing

12.28.2008
Email
Views: 2968
  • submit to reddit

Customizing

The end all be all definitive guide on how to customize a ToolTip is Dave Relyea’s post.  He shows a very clean and concise step by step on how to completely change the visuals of a ToolTip.  http://blogs.msdn.com/devdave/archive/2008/10/18/customizing-a-tooltip.aspx

Positioning

Positioning a ToolTip can be done with HorizontalOffset and VerticalOffset.  The biggest drawback is the inability to place the tooltip exactly where you want through XAML.  It can be done by wiring up a MouseEnter event for the ToolTip and then calculating the offsets.

<Button x:Name="InfoButton" Content="info" Width="50" Height="25">

<ToolTipService.ToolTip>

<ToolTip HorizontalOffset="-40" VerticalOffset="-140">

<ToolTip.Content>

<Grid Width="70">

<Rectangle Fill="Blue" />

<TextBlock TextWrapping="Wrap" Foreground="White"
Text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam mattis," />

</Grid>

</ToolTip.Content>

</ToolTip>

</ToolTipService.ToolTip>

</Button>

Notice the nested ToolTip inside the ToolTipService.  This is where you set the horizontal and vertical offsets for the Tooltip.

 

References
Published at DZone with permission of Corey Schuman, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)