How To: Creating Tooltips in Silverlight 2

.NET ,Silverlight ,Tutorial
March 9, 2009

Tooltips are great additions to any interface and in this article I’m going to show you how to attach a tooltip to control in Silverlight 2.


To start, let’s assume that we have a button that we want to add a tooltip to:


[XAML]


[Rendered UI]



In order or us to attach a tooltip to our button we need to create a reference to the TooltipService.Tooltip inside the our button’s XAML declaration. We also need to setup the Tooltip.Content to tell the compiler what to show when the user hover’s to our button.


[XAML]


[Rendered UI (at runtime)]



The message “Hooray! I’m alive!” appeared when the user hovers over our button. We can also cutomize how our tooltip appears by adding more XAML elements in the Tooltip.Content property.


[XAML]


[Rendered UI (at runtime)]



Another customization that you might want to do is specifying the HorizontalOffset and the VerticalOffset. This allows you to specify where the tooltip will appear in reference to your target control.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.