Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight
Silverlight 3
ToolTip Class
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Silverlight 3

Other versions are also available for the following:
.NET Framework Class Library for Silverlight
ToolTip Class

Represents a control that creates a pop-up window that displays information for an element in the UI.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
Visual Basic (Declaration)
<TemplateVisualStateAttribute(Name := "Closed", GroupName := "OpenStates")> _
<TemplateVisualStateAttribute(Name := "Open", GroupName := "OpenStates")> _
Public Class ToolTip _
    Inherits ContentControl
Visual Basic (Usage)
Dim instance As ToolTip
C#
[TemplateVisualStateAttribute(Name = "Closed", GroupName = "OpenStates")]
[TemplateVisualStateAttribute(Name = "Open", GroupName = "OpenStates")]
public class ToolTip : ContentControl
XAML Object Element Usage
<ToolTip .../>

You use a ToolTip control to provide information to the user. For example, you can use a ToolTip to provide the name of a Button. The content of a ToolTip control can vary from a simple text string to more complex content, such as a StackPanel that has embedded text and images. The content of a ToolTip cannot receive focus.

The properties of the ToolTip class are used to define the position and behavior of the tooltip. To add a ToolTip to a control, use the ToolTip attached property. For more information, see ToolTipService.

Customizing the ToolTip Control

To apply the same property settings to multiple ToolTip controls, use the Style property. To change the visual structure and visual behavior of a ToolTip, copy and modify its default style and template. For more information, see Control Customization.

If a dependency property for a ToolTip is set by its default style, the property might change from its default value when the ToolTip appears in the application. For more information, see Dependency Property Value Precedence. You can get the default style and template for ToolTip from ToolTip Styles and Templates.

NoteNote:

Setting a visual property will only have an effect if that property is both present in ToolTip control's default template and is set by using a TemplateBinding. You can find a list of visual properties in the "Changing the Visual Structure of a Control" section of Customizing the Appearance of an Existing Control by Using a ControlTemplate.

The following XAML demonstrates basic tooltips, and the properties for placement.

Run this sample

XAML
<UserControl x:Class="ToolTipExample.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="60" Canvas.Left="20" 
                Content="Button with a simple ToolTip." 
                ToolTipService.ToolTip="Simple ToolTip" />

        <!-- A TextBlock with an offset ToolTip. -->
        <TextBlock Text="TextBlock with an offset ToolTip." 
                   Canvas.Top="110" Canvas.Left="20" >
            <ToolTipService.ToolTip > 
                <ToolTip Content="Offset ToolTip." 
                HorizontalOffset="20" VerticalOffset="30"/>
            </ToolTipService.ToolTip>
        </TextBlock>

    </Canvas>
</UserControl>
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker