ToolTipService Class

Represents a service that provides properties and events to control the display and behavior of tooltips.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public static class ToolTipService
You cannot directly create an instance of this class in XAML.

You define a tooltip for an element by setting the FrameworkContentElement.ToolTip or FrameworkElement.ToolTip property. The ToolTip property takes one child. The content of the child can vary from a simple text string to more complex content such as a StackPanel that has embedded text and Image elements.

You can define tooltip content as a ToolTip object, but this is not required. When you do not define the tooltip content as a ToolTip object, you can use the ToolTipService properties to position and customize the tooltip content. The ToolTipService class attached properties are used to determine the placement, behavior, and appearance of a tooltip. These properties are set on the element that defines the tooltip.

The ToolTip class and the ToolTipService class share many of the same properties that are used to customize a tooltip. If equivalent ToolTip and ToolTipService properties are both set, the ToolTipService property takes precedence. For example, if both the ToolTip.Placement property and the ToolTipService.Placement property are set for a System.Windows.Controls.ToolTip object, the value of the ToolTipService.Placement property is used.

The following ToolTipService timing properties are only defined for the ToolTipService class and are used by all tooltips:

For information about how to handle the events that occur when the tooltip opens or closes, see the ToolTipOpeningEvent and ToolTipClosingEvent fields.

Placement, PlacementRectangle, PlacementTarget, HorizontalOffset, and VerticalOffset behave similarly to the properties of the same name in the Popup class. For more information, see Popup Placement Behavior.

The following example shows how the use the ToolTipService class to specify the behavior of a tooltip. You set the properties of the ToolTipService class by attaching them directly to the element that exposes the tooltip.

<Ellipse Height="25" Width="50" 
     Fill="Gray" 
     HorizontalAlignment="Left"
     ToolTipService.InitialShowDelay="1000"
     ToolTipService.ShowDuration="7000"
     ToolTipService.BetweenShowDelay="2000"
     ToolTipService.Placement="Right" 
     ToolTipService.PlacementRectangle="50,0,0,0"
     ToolTipService.HorizontalOffset="10" 
     ToolTipService.VerticalOffset="20"
     ToolTipService.HasDropShadow="false"
     ToolTipService.ShowOnDisabled="true" 
     ToolTipService.IsEnabled="true"
     ToolTipOpening="whenToolTipOpens"
     ToolTipClosing="whenToolTipCloses"
     >
  <Ellipse.ToolTip>
    <BulletDecorator>
      <BulletDecorator.Bullet>
        <Ellipse Height="10" Width="20" Fill="Blue"/>
      </BulletDecorator.Bullet>
      <TextBlock>Uses the ToolTipService class</TextBlock>
    </BulletDecorator>
  </Ellipse.ToolTip>
</Ellipse>

More Code

How to: Position a ToolTip This example shows how to specify the position of a tooltip on the screen.
How to: Use the BetweenShowDelay Property This example shows how to use the BetweenShowDelay time property so that tooltips appear quickly—with little or no delay—when a user moves the mouse pointer from one tooltip directly to another.

System.Object
  System.Windows.Controls.ToolTipService

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

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft