Page view counter

Silverlight Tips of the Day - Blog by Mike Snow

Game Programming with Silverlight

Silverlight Tip of the Day #61 – How to Create a Tooltip

If you have a FrameworkElement such as an Image, Button, TextBlock, etc. you can add a tooltip to the element. Tooltips are usually small, boxed text that popup when a user hovers over the control. The purpose of the tooltip is to tell the user what the control does.

For example, let’s say we have a toolbar of flags that represent the language a user can select:

image

If a user did not recognize a flag they could hover over it and the tooltip would say what language the flag represents. For example:

image

To add a Tooltip to a FrameworkElement all you have to do is declare the property TooltipService.Tooltip. For Example:

<Image Source="images/france.png" ToolTipService.ToolTip="French">

A tooltip does not have to only be text, rather a tooltip can be any control you declare. For example, to make a tooltip an image you would declare it as:

<Image Source="images/france.png" Width="16" Height="16">
    <ToolTipService.ToolTip>
        <Image Source="images/france.png"></Image>
    </ToolTipService.ToolTip>
</Image>

The result when hovering over the French flag would be the French flag at its original size:

image

Thank you,
--Mike Snow

 Subscribe in a reader

Comments

Microsoft Weblogs said:

If you have a FrameworkElement such as an Image , Button, TextBlock , etc. you can add a tooltip to the

# October 15, 2008 6:08 PM

noluckmurphy said:

I've noticed an issue in Silverlight 2 in which dynamically setting a tooltip (via the static ToolTipService methods) will erase any Style applied to the tooltip.

It was a problem in SL beta 2 and continues to be an issue in the release bits...

Any thoughts?

# October 15, 2008 8:10 PM

StefanOlson said:

Mike,

I wonder if you could post another tip about how you could easily set the data context of the tooltip.  I haven't been successful in finding a decent way to get that to work and given that my tooltips all contain bindings, it is extremely frustrating.  It works perfectly in WPF without having to do anything, I wish Silverlight worked that way too!

...Stefan

# October 15, 2008 8:26 PM

H?????ng d???n c??ch d??ng ToolTip « Nam Gi?? said:

Pingback from  H?????ng d???n c??ch d??ng ToolTip &laquo; Nam Gi??

# October 15, 2008 11:16 PM

2008 October 16 - Links for today « My (almost) Daily Links said:

Pingback from  2008 October 16 - Links for today &laquo; My (almost) Daily Links

# October 16, 2008 5:46 AM

Silverlight news for October 16, 2008 said:

Pingback from  Silverlight news for October 16, 2008

# October 16, 2008 8:45 AM

Dew Drop - October 16, 2008 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - October 16, 2008 | Alvin Ashcraft's Morning Dew

# October 16, 2008 9:33 AM

Yellow said:

Silverlight2DataGridisReleased

ScottMorrison对Silverlight2中的DataGrid控件的新特性进行了介绍,包括Accessibili...

# October 16, 2008 11:09 PM

surbhiydv said:

Thanks Mike for the post.

How can I customize look of tooltip? what are the properties supported for tooltipservice by style setter?

# October 17, 2008 2:35 AM

Community Blogs said:

In this issue: Tim Heuer, Pete Brown, Mike Taulty, NikhilKothari, Dan Wahlin, Laurence Moroney, Arturo

# October 18, 2008 1:25 AM

Visual Web Developer Team Blog said:

Silverlight Tip of the Day #66 Title: How to copy XAML for Silverlight from Expression Designer Silverlight

# November 3, 2008 1:41 PM

Silverlight Tips of the Day - Blog by Mike Snow said:

The purpose of this post is to create an outline summary all the blogs from my Silverlight tips of the

# January 2, 2009 5:56 PM

o UAU nosso de cada dia said:

essa lista eu copiei desse blog bárbaro (acompanhe por RSS você também): uma lista de dicas super úteis

# January 3, 2009 6:25 AM

??????????????? ??? ?????? « jin_u as blog said:

Pingback from  ??????????????? ??? ?????? &laquo; jin_u as blog

# March 24, 2009 10:02 PM