Skip to main content
.NET Framework Class Library
ToolTipService Class

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

Inheritance Hierarchy
SystemObject
  System.Windows.ControlsToolTipService

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
Syntax
Public NotInheritable Class ToolTipService
public static class ToolTipService
public ref class ToolTipService abstract sealed
[<[%$TOPIC/ms617640_en-us_VS_110_2_0_3_0_0%]>]
[<[%$TOPIC/ms617640_en-us_VS_110_2_0_3_0_1%]>]
type ToolTipService =  class end

The ToolTipService type exposes the following members.

Attached Properties
  NameDescription
Public attached property BetweenShowDelayGets or sets the maximum time between the display of two tooltips where the second tooltip appears without a delay.
Public attached property HasDropShadowGets or sets whether the tooltip displays a drop shadow effect.
Public attached property HorizontalOffsetGets or sets the offset from the left of the area that is specified for the tooltip by the PlacementRectangle and PlacementTarget properties.
Public attached property InitialShowDelayGets or sets the length of time before a tooltip opens.
Public attached property IsEnabledGets or sets whether a tooltip appears.
Public attached property IsOpenGets whether a tooltip is currently visible.
Public attached property PlacementGets or sets the orientation of the tooltip when it opens, and specifies how the tooltip behaves when it overlaps screen boundaries.
Public attached property PlacementRectangleGets or sets the rectangular area relative to which the tooltip is positioned.
Public attached property PlacementTargetGets or sets the object relative to which the tooltip is positioned.
Public attached property ShowDurationGets or sets the amount of time that a tooltip remains visible.
Public attached property ShowOnDisabledGets or sets whether a tooltip appears for an object that is not enabled.
Public attached property ToolTipGets or sets the content of a tooltip.
Public attached property VerticalOffsetGets or sets the distance from the top of the area that is specified for the tooltip by the PlacementRectangle and PlacementTarget properties.
Top
Methods
  NameDescription
Public method Static member AddToolTipClosingHandlerAdds a handler for the ToolTipClosing attached event.
Public method Static member AddToolTipOpeningHandlerAdds a handler for the ToolTipOpening attached event.
Public method Static member GetBetweenShowDelayGets the value of the BetweenShowDelay attached property for an object.
Public method Static member GetHasDropShadowGets the value of the HasDropShadow attached property for an object.
Public method Static member GetHorizontalOffsetGets the value of the HorizontalOffset attached property for an object.
Public method Static member GetInitialShowDelayGets the value of the InitialShowDelay attached property for an object.
Public method Static member GetIsEnabledGets the value of the IsEnabled attached property for an object.
Public method Static member GetIsOpenGets the value of the IsOpen attached property for an object.
Public method Static member GetPlacementGets the value of the Placement attached property for an object.
Public method Static member GetPlacementRectangleGets the value of the PlacementRectangle attached property for an object.
Public method Static member GetPlacementTargetGets the value of the PlacementTarget attached property for an object.
Public method Static member GetShowDurationGets the value of the ShowDuration attached property for an object.
Public method Static member GetShowOnDisabledGets the value of the ShowOnDisabled attached property for an object.
Public method Static member GetToolTipGets the value of the ToolTip attached property for an object.
Public method Static member GetVerticalOffsetGets the value of the VerticalOffset attached property for an object.
Public method Static member RemoveToolTipClosingHandlerRemoves a handler for the ToolTipClosing attached event.
Public method Static member RemoveToolTipOpeningHandlerRemoves a handler for the ToolTipOpening attached event.
Public method Static member SetBetweenShowDelaySets the value of the BetweenShowDelay attached property for an object.
Public method Static member SetHasDropShadowSets the value of the HasDropShadow attached property for an object.
Public method Static member SetHorizontalOffsetSets the value of the HorizontalOffset attached property for an object.
Public method Static member SetInitialShowDelaySets the value of the InitialShowDelay attached property for an object.
Public method Static member SetIsEnabledSets the value of the IsEnabled attached property for an object.
Public method Static member SetPlacementSets the value of the Placement attached property for an object.
Public method Static member SetPlacementRectangleSets the value of the PlacementRectangle attached property for an object.
Public method Static member SetPlacementTargetSets the value of the PlacementTarget attached property for an object.
Public method Static member SetShowDurationSets the value of the ShowDuration attached property for an object.
Public method Static member SetShowOnDisabledSets the value of the ShowOnDisabled attached property for an object.
Public method Static member SetToolTipSets the value of the ToolTip attached property for an object.
Public method Static member SetVerticalOffsetSets the value of the VerticalOffset attached property for an object.
Top
Attached Events
  NameDescription
Public attached event ToolTipClosingOccurs when the ToolTip closes.
Public attached event ToolTipOpeningOccurs when the ToolTip opens.
Top
Fields
  NameDescription
Public field Static member BetweenShowDelayPropertyIdentifies the BetweenShowDelay attached property.
Public field Static member HasDropShadowPropertyIdentifies the HasDropShadow attached property.
Public field Static member HorizontalOffsetPropertyIdentifies the HorizontalOffset attached property.
Public field Static member InitialShowDelayPropertyIdentifies the InitialShowDelay attached property.
Public field Static member IsEnabledPropertyIdentifies the IsEnabled attached property.
Public field Static member IsOpenPropertyIdentifies the IsOpen attached property.
Public field Static member PlacementPropertyIdentifies the Placement attached property.
Public field Static member PlacementRectanglePropertyIdentifies the PlacementRectangle attached property.
Public field Static member PlacementTargetPropertyIdentifies the PlacementTarget attached property.
Public field Static member ShowDurationPropertyIdentifies the ShowDuration attached property.
Public field Static member ShowOnDisabledPropertyIdentifies the ShowOnDisabled attached property.
Public field Static member ToolTipClosingEventIdentifies the ToolTipClosing event that is exposed by objects that use the ToolTipService service to display tooltips.
Public field Static member ToolTipOpeningEventIdentifies the ToolTipOpening event that is exposed by objects that use the ToolTipService service to display tooltips.
Public field Static member ToolTipPropertyIdentifies the ToolTip attached property.
Public field Static member VerticalOffsetPropertyIdentifies the VerticalOffset attached property.
Top
Remarks

You define a tooltip for an element by setting the FrameworkContentElementToolTip or FrameworkElementToolTip 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 ToolTipPlacement property and the ToolTipServicePlacement property are set for a System.Windows.ControlsToolTip object, the value of the ToolTipServicePlacement 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.

Examples

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 ToolTipThis example shows how to specify the position of a tooltip on the screen.
How to: Use the BetweenShowDelay PropertyThis 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.
Version Information

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

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.