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.

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”.
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.
And the target control will get its tooltip style set.

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.
And here it is! The button is not clickable though :).

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




