Export (0) Print
Expand All
0 out of 2 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.

  NameDescription
Public attached propertySupported by Silverlight for Windows PhonePlacementGets or sets the position of the tooltip in relation to its target visual element.
Public attached propertySupported by Silverlight for Windows PhonePlacementTargetGets or sets the visual element that the tooltip should be positioned in relation to.
Public attached propertySupported by Silverlight for Windows PhoneToolTipGets or sets a tooltip to be attached to a control.
Top
  NameDescription
Public methodStatic memberSupported by Silverlight for Windows PhoneGetPlacementGets the relative position of the specified tooltip.
Public methodStatic memberSupported by Silverlight for Windows PhoneGetPlacementTargetGets the visual element that the tooltip is positioned relative to.
Public methodStatic memberSupported by Silverlight for Windows PhoneGetToolTipGets the tooltip for an object.
Public methodStatic memberSupported by Silverlight for Windows PhoneSetPlacementSets the position of the specified ToolTip using the specified placement mode.
Public methodStatic memberSupported by Silverlight for Windows PhoneSetPlacementTargetSets the position of the specified ToolTip relative to the specified value element.
Public methodStatic memberSupported by Silverlight for Windows PhoneSetToolTipSets the tooltip for an object.
Top
  NameDescription
Public fieldStatic memberSupported by Silverlight for Windows PhonePlacementPropertyIdentifies the Placement dependency property.
Public fieldStatic memberSupported by Silverlight for Windows PhonePlacementTargetPropertyIdentifies the PlacementTarget dependency property.
Public fieldStatic memberSupported by Silverlight for Windows PhoneToolTipPropertyIdentifies 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)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.