Export (0) Print
Expand All

ToolTipService Class

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

System.Object
  System.Windows.Controls.ToolTipService

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

public static class ToolTipService

The ToolTipService type exposes the following members.

  NameDescription
Public attached propertyBetweenShowDelayGets or sets the maximum time between the display of two tooltips where the second tooltip appears without a delay.
Public attached propertyHasDropShadowGets or sets whether the tooltip displays a drop shadow effect.
Public attached propertyHorizontalOffsetGets or sets the offset from the left of the area that is specified for the tooltip by the PlacementRectangle and PlacementTarget properties.
Public attached propertyInitialShowDelayGets or sets the length of time before a tooltip opens.
Public attached propertyIsEnabledGets or sets whether a tooltip appears.
Public attached propertyIsOpenGets whether a tooltip is currently visible.
Public attached propertyPlacementGets or sets the orientation of the tooltip when it opens, and specifies how the tooltip behaves when it overlaps screen boundaries.
Public attached propertyPlacementRectangleGets or sets the rectangular area relative to which the tooltip is positioned.
Public attached propertyPlacementTargetGets or sets the object relative to which the tooltip is positioned.
Public attached propertyShowDurationGets or sets the amount of time that a tooltip remains visible.
Public attached propertyShowOnDisabledGets or sets whether a tooltip appears for an object that is not enabled.
Public attached propertyToolTipGets or sets the content of a tooltip.
Public attached propertyVerticalOffsetGets or sets the distance from the top of the area that is specified for the tooltip by the PlacementRectangle and PlacementTarget properties.
Top

  NameDescription
Public methodStatic memberGetBetweenShowDelayGets the value of the BetweenShowDelay attached property for an object.
Public methodStatic memberGetHasDropShadowGets the value of the HasDropShadow attached property for an object.
Public methodStatic memberGetHorizontalOffsetGets the value of the HorizontalOffset attached property for an object.
Public methodStatic memberGetInitialShowDelayGets the value of the InitialShowDelay attached property for an object.
Public methodStatic memberGetIsEnabledGets the value of the IsEnabled attached property for an object.
Public methodStatic memberGetIsOpenGets the value of the IsOpen attached property for an object.
Public methodStatic memberGetPlacementGets the value of the Placement attached property for an object.
Public methodStatic memberGetPlacementRectangleGets the value of the PlacementRectangle attached property for an object.
Public methodStatic memberGetPlacementTargetGets the value of the PlacementTarget attached property for an object.
Public methodStatic memberGetShowDurationGets the value of the ShowDuration attached property for an object.
Public methodStatic memberGetShowOnDisabledGets the value of the ShowOnDisabled attached property for an object.
Public methodStatic memberGetToolTipGets the value of the ToolTip attached property for an object.
Public methodStatic memberGetVerticalOffsetGets the value of the VerticalOffset attached property for an object.
Public methodStatic memberSetBetweenShowDelaySets the value of the BetweenShowDelay attached property for an object.
Public methodStatic memberSetHasDropShadowSets the value of the HasDropShadow attached property for an object.
Public methodStatic memberSetHorizontalOffsetSets the value of the HorizontalOffset attached property for an object.
Public methodStatic memberSetInitialShowDelaySets the value of the InitialShowDelay attached property for an object.
Public methodStatic memberSetIsEnabledSets the value of the IsEnabled attached property for an object.
Public methodStatic memberSetPlacementSets the value of the Placement attached property for an object.
Public methodStatic memberSetPlacementRectangleSets the value of the PlacementRectangle attached property for an object.
Public methodStatic memberSetPlacementTargetSets the value of the PlacementTarget attached property for an object.
Public methodStatic memberSetShowDurationSets the value of the ShowDuration attached property for an object.
Public methodStatic memberSetShowOnDisabledSets the value of the ShowOnDisabled attached property for an object.
Public methodStatic memberSetToolTipSets the value of the ToolTip attached property for an object.
Public methodStatic memberSetVerticalOffsetSets the value of the VerticalOffset attached property for an object.
Top

  NameDescription
Public fieldStatic memberBetweenShowDelayPropertyIdentifies the BetweenShowDelay attached property.
Public fieldStatic memberHasDropShadowPropertyIdentifies the HasDropShadow attached property.
Public fieldStatic memberHorizontalOffsetPropertyIdentifies the HorizontalOffset attached property.
Public fieldStatic memberInitialShowDelayPropertyIdentifies the InitialShowDelay attached property.
Public fieldStatic memberIsEnabledPropertyIdentifies the IsEnabled attached property.
Public fieldStatic memberIsOpenPropertyIdentifies the IsOpen attached property.
Public fieldStatic memberPlacementPropertyIdentifies the Placement attached property.
Public fieldStatic memberPlacementRectanglePropertyIdentifies the PlacementRectangle attached property.
Public fieldStatic memberPlacementTargetPropertyIdentifies the PlacementTarget attached property.
Public fieldStatic memberShowDurationPropertyIdentifies the ShowDuration attached property.
Public fieldStatic memberShowOnDisabledPropertyIdentifies the ShowOnDisabled attached property.
Public fieldStatic memberToolTipClosingEventIdentifies the ToolTipClosing event that is exposed by objects that use the ToolTipService service to display tooltips.
Public fieldStatic memberToolTipOpeningEventIdentifies the ToolTipOpening event that is exposed by objects that use the ToolTipService service to display tooltips.
Public fieldStatic memberToolTipPropertyIdentifies the ToolTip attached property.
Public fieldStatic memberVerticalOffsetPropertyIdentifies the VerticalOffset attached property.
Top

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

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

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

Community Additions

ADD
Show:
© 2014 Microsoft