If you are anything like myself, you may have noticed that some of the new controls have a property labeled Tooltip. A good example of this is the button object, so in your xaml you can specify the following:
<Button Content=”I am a Button” Tooltip=”Hello World” />
And just like that you will notice that the button will present a common tooltip of “Hello World”. But what about tooltips on things that do not have a Tooltip property. A good example is a layout control like the Canvas. Well in trying to figure this out, I looked at intellesense in Visual Studio and noticed a ToolTipService property; however, setting the property as I would intuitively do to something like (<Canvas ToolTipService.Tooltip=”Hello World”></Canvas>) was not working. In further investigating the scenario I found that you have to do two things:
1. Add a namespace to the additional Controls DLL of System.Windows.Controls:
<UserControl x:Class=”SomeClass”
xmlns=”http://schemas.microsoft.com/client/2007″
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
xmlns:control=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls”
….
2. In the object you want to add the Tooltip functionality, inside its container specify the tooltip service; however, the tooltip property of the tooltip service wants to be set to an instance of a tooltip object and not a string:
<Canvas x:Name=”SomeCanvas” Background=”Green” Width=”100″ Height=”100″>
<control:ToolTipService.ToolTip>
<ToolTip Content=”Hello World” />
</control:ToolTipService.ToolTip>
</Canvas>
And viola, a canvas now has a Tooltip property.