ToolTipService Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a service that provides properties and events to control the display and behavior of tooltips.
public ref class ToolTipService abstract sealed
public static class ToolTipService
type ToolTipService = class
Public Class ToolTipService
- Inheritance
-
ToolTipService
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>
Remarks
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. Attached properties of the ToolTipService class 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.
Fields
BetweenShowDelayProperty |
Identifies the BetweenShowDelay attached property. |
HasDropShadowProperty |
Identifies the HasDropShadow attached property. |
HorizontalOffsetProperty |
Identifies the HorizontalOffset attached property. |
InitialShowDelayProperty |
Identifies the InitialShowDelay attached property. |
IsEnabledProperty |
Identifies the IsEnabled attached property. |
IsOpenProperty |
Identifies the IsOpen attached property. |
PlacementProperty |
Identifies the Placement attached property. |
PlacementRectangleProperty |
Identifies the PlacementRectangle attached property. |
PlacementTargetProperty |
Identifies the PlacementTarget attached property. |
ShowDurationProperty |
Identifies the ShowDuration attached property. |
ShowOnDisabledProperty |
Identifies the ShowOnDisabled attached property. |
ShowsToolTipOnKeyboardFocusProperty | |
ToolTipClosingEvent |
Identifies the ToolTipClosing event that is exposed by objects that use the ToolTipService service to display tooltips. |
ToolTipOpeningEvent |
Identifies the ToolTipOpening event that is exposed by objects that use the ToolTipService service to display tooltips. |
ToolTipProperty |
Identifies the ToolTip attached property. |
VerticalOffsetProperty |
Identifies the VerticalOffset attached property. |
Attached Properties
BetweenShowDelay |
Gets or sets the maximum time between the display of two tooltips where the second tooltip appears without a delay. |
HasDropShadow |
Gets or sets whether the tooltip displays a drop shadow effect. |
HorizontalOffset |
Gets or sets the offset from the left of the area that is specified for the tooltip by the PlacementRectangle and PlacementTarget properties. |
InitialShowDelay |
Gets or sets the length of time before a tooltip opens. |
IsEnabled |
Gets or sets whether a tooltip appears. |
IsOpen |
Gets whether a tooltip is currently visible. |
Placement |
Gets or sets the orientation of the tooltip when it opens, and specifies how the tooltip behaves when it overlaps screen boundaries. |
PlacementRectangle |
Gets or sets the rectangular area relative to which the tooltip is positioned. |
PlacementTarget |
Gets or sets the object relative to which the tooltip is positioned. |
ShowDuration |
Gets or sets the amount of time that a tooltip remains visible. |
ShowOnDisabled |
Gets or sets whether a tooltip appears for an object that is not enabled. |
ShowsToolTipOnKeyboardFocus | |
ToolTip |
Gets or sets the content of a tooltip. |
VerticalOffset |
Gets or sets the distance from the top of the area that is specified for the tooltip by the PlacementRectangle and PlacementTarget properties. |
Methods
Attached Events
ToolTipClosing |
Occurs when the ToolTip closes. |
ToolTipOpening |
Occurs when the ToolTip opens. |