Represents a control that creates a pop-up window that displays information for an element in the UI.
<TemplateVisualStateAttribute(Name := "Closed", GroupName := "OpenStates")> _ <TemplateVisualStateAttribute(Name := "Open", GroupName := "OpenStates")> _ Public Class ToolTip _ Inherits ContentControl
Dim instance As ToolTip
[TemplateVisualStateAttribute(Name = "Closed", GroupName = "OpenStates")] [TemplateVisualStateAttribute(Name = "Open", GroupName = "OpenStates")] public class ToolTip : ContentControl
<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.
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.
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
<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>
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.