0 out of 1 rated this helpful - Rate this topic

ToolTipService Class

Represents a service that provides static methods to display a tooltip.

System.Object
  System.Windows.Controls.ToolTipService

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
public static class ToolTipService

The ToolTipService type exposes the following members.

  Name Description
Public attached property Supported by Silverlight for Windows Phone Placement Gets or sets the position of the tooltip in relation to its target visual element.
Public attached property Supported by Silverlight for Windows Phone PlacementTarget Gets or sets the visual element that the tooltip should be positioned in relation to.
Public attached property Supported by Silverlight for Windows Phone ToolTip Gets or sets a tooltip to be attached to a control.
Top
  Name Description
Public method Static member Supported by Silverlight for Windows Phone GetPlacement Gets the relative position of the specified tooltip.
Public method Static member Supported by Silverlight for Windows Phone GetPlacementTarget Gets the visual element that the tooltip is positioned relative to.
Public method Static member Supported by Silverlight for Windows Phone GetToolTip Gets the tooltip for an object.
Public method Static member Supported by Silverlight for Windows Phone SetPlacement Sets the position of the specified ToolTip using the specified placement mode.
Public method Static member Supported by Silverlight for Windows Phone SetPlacementTarget Sets the position of the specified ToolTip relative to the specified value element.
Public method Static member Supported by Silverlight for Windows Phone SetToolTip Sets the tooltip for an object.
Top
  Name Description
Public field Static member Supported by Silverlight for Windows Phone PlacementProperty Identifies the Placement dependency property.
Public field Static member Supported by Silverlight for Windows Phone PlacementTargetProperty Identifies the PlacementTarget dependency property.
Public field Static member Supported by Silverlight for Windows Phone ToolTipProperty Identifies the ToolTip dependency property.
Top

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.

The following code example demonstrates the placement modes for a tooltip.

Run this sample


<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>


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ