ToolTipService class

Applies to Windows and Windows Phone

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

Inheritance

Object
  ToolTipService

Syntax


public sealed class ToolTipService

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

Members

The ToolTipService class has these types of members:

Methods

The ToolTipService class has these methods. It also inherits methods from the Object class.

MethodDescription
GetPlacement Gets the ToolTipService.Placement XAML attached property value for the specified target element.
GetPlacementTarget Gets the ToolTipService.PlacementTarget XAML attached property value for the specified target element.
GetToolTip Gets the value of the ToolTipService.ToolTip XAML attached property for an object.
SetPlacement Sets the ToolTipService.Placement XAML attached property value for the specified target element.
SetPlacementTarget Sets the ToolTipService.PlacementTarget XAML attached property value for the specified target element.
SetToolTip Sets the value of the ToolTipService.ToolTip XAML attached property.

 

Attached Properties

The ToolTipService class has these attached properties.

Access typeDescription

ToolTipService.Placement

Read/writeGets or sets how a ToolTip is positioned in relation to the placement target.

ToolTipService.PlacementTarget

Read/writeGets or sets the object relative to which a tooltip is positioned.

ToolTipService.Tooltip

Read/writeGets or sets the object or string content of an element's ToolTip.

 

Properties

The ToolTipService class has these properties.

PropertyAccess typeDescription

PlacementProperty

Read-onlyIdentifies the ToolTipService.Placement XAML attached property.

PlacementTargetProperty

Read-onlyIdentifies the ToolTipService.PlacementTarget XAML attached property.

ToolTipProperty

Read-onlyIdentifies the ToolTipService.ToolTip XAML attached property.

 

Remarks

ToolTipService XAML attached properties

ToolTipService is the host service class for several Extensible Application Markup Language (XAML) attached properties. The purpose of these attached properties is to enable target elements to qualify how they should be positioned relative to placement target elements.

ToolTipService provides the following attached properties for XAML usage:

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. For example, the GetPlacement and SetPlacement methods support and provide the equivalent code-only support for ToolTipService.Placement. Alternatively, you can use the dependency property system to get or set the value of the attached property. Call GetValue or SetValue, passing the arguments of the dependency property identifier to set, and a reference to the target object on which to get or set the value.

A ToolTip must be assigned to another UI element that is its owner. In 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.

Examples

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


<StackPanel Margin="120" >
<TextBlock Text="ToolTip Control" Margin="5" 
           Style="{StaticResource HeaderTextStyle}" />
<TextBlock Text="Hover over an item to see its ToolTip: " 
           Style="{StaticResource ItemTextStyle}" Margin="10" />
<ListBox Width="100">
    <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>


For more examples, see the XAML essential controls sample.

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

ToolTip
How to add a tooltip
XAML essential controls sample

 

 

Show:
© 2014 Microsoft