ToolTipService Class

Definition

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

public ref class ToolTipService sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ToolTipService final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ToolTipService
Public NotInheritable Class ToolTipService
Inheritance
Object Platform::Object IInspectable ToolTipService
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

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

<StackPanel Margin="120" >
    <TextBlock Text="ToolTip Control"/>
    <TextBlock Text="Hover over an item to see its ToolTip: " Margin="0,10"/>
    <ListBox Width="100" HorizontalAlignment="Left">
        <ListBoxItem Content="Left" 
            ToolTipService.ToolTip="ToolTip to the left." 
            ToolTipService.Placement="Left" />
        <ListBoxItem Content="Right" 
            ToolTipService.ToolTip="ToolTip to the right." 
            ToolTipService.Placement="Right" />
        <ListBoxItem Content="Top" 
            ToolTipService.ToolTip="ToolTip at the top." 
            ToolTipService.Placement="Top" />
        <ListBoxItem Content="Bottom" 
            ToolTipService.ToolTip="ToolTip at the bottom." 
            ToolTipService.Placement="Bottom"/>
        <ListBoxItem Content="Mouse" 
            ToolTipService.ToolTip="ToolTip based on the cursor position." 
            ToolTipService.Placement="Mouse"/>
    </ListBox>
</StackPanel>

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

Notes for previous versions

Windows 8.x ToolTip is intended only for use in Windows. The ToolTip type is available in Windows Phone projects for compatibility with universal project templates, but the ToolTip is not shown in the Windows Phone UI.

ToolTip is displayed only within the bounds of the app window. It's placement might be adjusted to stay within those bounds.

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.

Properties

PlacementProperty

Identifies the ToolTipService.Placement XAML attached property.

PlacementTargetProperty

Identifies the ToolTipService.PlacementTarget XAML attached property.

ToolTipProperty

Identifies the ToolTipService.ToolTip XAML attached property.

Attached Properties

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.

Methods

GetPlacement(DependencyObject)

Gets the ToolTipService.Placement XAML attached property value for the specified target element.

GetPlacementTarget(DependencyObject)

Gets the ToolTipService.PlacementTarget XAML attached property value for the specified target element.

GetToolTip(DependencyObject)

Gets the value of the ToolTipService.ToolTip XAML attached property for an object.

SetPlacement(DependencyObject, PlacementMode)

Sets the ToolTipService.Placement XAML attached property value for the specified target element.

SetPlacementTarget(DependencyObject, UIElement)

Sets the ToolTipService.PlacementTarget XAML attached property value for the specified target element.

SetToolTip(DependencyObject, Object)

Sets the value of the ToolTipService.ToolTip XAML attached property.

Applies to

See also