Silverlight 2: Styling the control ToolTip

Working with control tooltip in Silverlight 2 (Beta 2) can be a bit tricky. As of Beta 2, it’s not as straight forward as it is in WPF. In this post I’ll show an easy way to create and customize tooltip style of Silverlight control.

At the very basic, you can add a default tooltip to Silverlight control by nesting ToolTipService.ToolTip dependency property in the XAML. What you’ll get is the default tooltip that looks like this.

Default Silverlight control tooltip

In this example, I’ll use the WPF tooltip style created by Lee Brimelow. I change it a little to make it work on Silverlight. I add this style to my App.xaml so that it’s available throughout the application. Name it “ToolTipStyle”.

Styling the tooltip in App.xaml

Next, in the control, I just set the style to "{StaticResource ToolTipStyle}" and also set the text content that will show up in the tooltip box.

Setting control tooltip

And the target control will get its tooltip style set.

Tooltip style customized

Note here is the use of ContentPresenter in the style template. ContentPresenter allows you to customize the look of tooltip content even further. Let’s stay I want to put a button in my tooltip.

UIElement as tooltip content

And here it is! The button is not clickable though :).

Teera on June 15th 2008 in Silverlight, Software Development, .NET

2 Responses to “Silverlight 2: Styling the control ToolTip”

  1. fasih hansmukh responded on 10 Jul 2008 at 6:13 am #

    wow..tht saved lot of my time..good work dude..

  2. Shemesh responded on 12 Aug 2008 at 3:57 am #

    i second the first comment!
    “…saved lot of my time..good work dude..”

Trackback URI | Comments RSS

Leave a Reply