Export (0) Print
Expand All

ToolTipService Class

Represents a service that provides properties and events to control the display and behavior of tooltips. This class cannot be inherited.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public static class ToolTipService
public final class ToolTipService
public final class ToolTipService
You cannot use this managed class in XAML.

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. 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, the ToolTipService properties are used to position and customize the tooltip content.

The following example shows a tooltip that is defined for a TextBox and that uses the InitialShowDelay attached property of the ToolTipService to delay the appearance of the tooltip.

<TextBox HorizontalAlignment="Left" ToolTipService.InitialShowDelay="1500"
   ToolTip="Useful information goes here.">
     ToolTip with delay
</TextBox>

You define tooltips for an element by setting the ToolTip property of the element. The ToolTip property of an element is inherited either from FrameworkContentElement.ToolTip or from FrameworkElement.ToolTip.

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 by using a ToolTip object, but this is not required.

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.

This example shows how to set a ToolTipService property that causes a brief delay before a ToolTip displays. You set the properties of the ToolTipService class by attaching them directly to the element that exposes the tooltip.

<TextBox HorizontalAlignment="Left" ToolTipService.InitialShowDelay="1500"
   ToolTip="Useful information goes here.">
     ToolTip with delay
</TextBox>

For the complete sample from which the previous example was extracted, see ToolTip Sample. For a more extensive sample that shows how to get and set the ToolTipService properties in markup and also by using code, see ToolTipService Sample.

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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft