Establishing Tooltips

Silverlight controls can be configured to support tooltips. To do so, you must set the
ToolTipService.ToolTip property. The nested <ToolTip> type supports the Silverlight content model,
therefore your tooltip can be anything you desire. Consider the following markup.


<UserControl x:Class="SL_Controls.Page"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 Width="400" Height="300">

 <Canvas x:Name="LayoutRoot" Background="White">
   <!-- A button with a simple ToolTip. -->
   <Button x:Name="button1" Canvas.Top="40" Canvas.Left="20"
           Content="Button with a simple ToolTip."
           ToolTipService.ToolTip="Simple ToolTip" />

   <!-- A TextBlock with an complex / offset ToolTip. -->
   <TextBlock Text="TextBlock with an offset ToolTip."
              Canvas.Top="90" Canvas.Left="20" >
  
   <ToolTipService.ToolTip >
       <ToolTip HorizontalOffset="10" VerticalOffset="10">
         <ToolTip.Content>
           <StackPanel>
             <TextBlock Text="Cool!"/>
             <Rectangle Fill="Green" Height="30"/>
           </StackPanel>
         </ToolTip.Content>
       </ToolTip>
     </ToolTipService.ToolTip>
   </TextBlock>
 </Canvas>
</UserControl>
Tooltips
Table of Contents
Copyright (c) 2008.  Intertech, Inc. All Rights Reserved.  This information is to be used exclusively as an
online learning aid.  Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials
Services