ToolTipService Class
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Represents a service that provides static methods to display a tooltip.
Inheritance Hierarchy
System.Object
System.Windows.Controls.ToolTipService
Namespace: System.Windows.Controls
Assembly: System.Windows (in System.Windows.dll)
Syntax
'Declaration
Public NotInheritable Class ToolTipService
public static class ToolTipService
The ToolTipService type exposes the following members.
Attached Properties
Name | Description | |
---|---|---|
Placement | Gets or sets the position of the tooltip in relation to its target visual element. | |
PlacementTarget | Gets or sets the visual element that the tooltip should be positioned in relation to. | |
ToolTip | Gets or sets a tooltip to be attached to a control. |
Top
Methods
Name | Description | |
---|---|---|
GetPlacement | Gets the relative position of the specified tooltip. | |
GetPlacementTarget | Gets the visual element that the tooltip is positioned relative to. | |
GetToolTip | Gets the tooltip for an object. | |
SetPlacement | Sets the position of the specified ToolTip using the specified placement mode. | |
SetPlacementTarget | Sets the position of the specified ToolTip relative to the specified value element. | |
SetToolTip | Sets the tooltip for an object. |
Top
Fields
Name | Description | |
---|---|---|
PlacementProperty | Identifies the Placement dependency property. | |
PlacementTargetProperty | Identifies the PlacementTarget dependency property. | |
ToolTipProperty | Identifies the ToolTip dependency property. |
Top
Remarks
To display a tooltip for a control you must use the ToolTipService class. Use the static SetToolTip and GetToolTip methods to set and get the tooltip for a control.
Examples
The following code example demonstrates the placement modes for a tooltip.
<Border BorderThickness="3" BorderBrush="Black">
<StackPanel Background="LightGray">
<TextBlock Text="ToolTip Control" Margin="5" />
<StackPanel x:Name="LayoutRoot" Orientation="Horizontal">
<TextBlock TextWrapping="Wrap" Width="150" Text="Hover over an item to see its ToolTip: "
Margin="5" VerticalAlignment="Center" />
<ListBox Width="100" x:Name="myListBox" ToolTipService.ToolTip="ToolTip"
ToolTipService.Placement="Right" >
<ListBox.Items>
<ListBoxItem Content="Left" ToolTipService.ToolTip="ToolTip to the left."
ToolTipService.Placement="Left" />
<ListBoxItem Content="Right" ToolTipService.ToolTip="ToolTip to the right."
ToolTipService.Placement="Right" />
<ListBoxItem Content="Top" ToolTipService.ToolTip="ToolTip at the top."
ToolTipService.Placement="Top" />
<ListBoxItem Content="Bottom" ToolTipService.ToolTip="ToolTip at the bottom."
ToolTipService.Placement="Bottom"/>
<ListBoxItem Content="Mouse" ToolTipService.ToolTip="ToolTip based on the mouse."
ToolTipService.Placement="Mouse"/>
</ListBox.Items>
</ListBox>
</StackPanel>
</StackPanel>
</Border>
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.