Skip to content

Latest commit

 

History

History
47 lines (29 loc) · 4.23 KB

tooltipservice.md

File metadata and controls

47 lines (29 loc) · 4.23 KB
-api-id -api-type
T:Microsoft.UI.Xaml.Controls.ToolTipService
winrt class

Microsoft.UI.Xaml.Controls.ToolTipService

-description

Represents a service that provides static methods to display a ToolTip.

-remarks

A ToolTip must be assigned to another UI element that is its owner. In Extensible Application Markup Language (XAML), use the ToolTipService.ToolTip attached property to assign the ToolTip to an owner. In code, use the ToolTipService.SetToolTip method to assign the ToolTip to an owner.

Placement

By default, a ToolTip is displayed centered above the pointer. The placement is not constrained by the app window, so the ToolTip might be displayed partially or completely outside of the app window bounds.

If a ToolTip obscures the content it is referring to, you can adjust it's placement. Use the ToolTipService.Placement attached property to place the ToolTip above, below, left, or right of the pointer.

If there is no explicit PlacementTarget, the placement target for a tooltip is the element that specifies a value for its TooltipService.ToolTip attached property value. Any Placement value (either as an attached property or as an attribute on an explicit ToolTip element) applies to that target.

XAML attached properties

ToolTipService is the host service class for several XAML attached properties.

In order to support XAML processor access to the attached properties, and also to expose equivalent get and set operations to code, each XAML attached property has a pair of Get and Set accessor methods. Another way to get or set the value in code is to use the dependency property system, calling either GetValue or SetValue and passing the identifier field as the dependency property identifier.

Attached property Description
Placement Gets or sets a value that indicates how a ToolTip is positioned in relation to the placement target.
PlacementTarget Gets or sets the object relative to which a tooltip is positioned.
ToolTip Gets or sets the object or string content of an element's ToolTip.

-examples

The following code example demonstrates the placement modes for a ToolTip.

[!code-xaml1]

-see-also

ToolTip, How to add a tooltip, XAML essential controls sample