Tool Service Tip
Tool Service Tip
Tool Service Tip
public : sealed class ToolTipService : IToolTipService
struct winrt::Windows::UI::Xaml::Controls::ToolTipService : IToolTipService
public sealed class ToolTipService : IToolTipService
Public NotInheritable Class ToolTipService Implements IToolTipService
Windows 10 (introduced v10.0.10240.0)
Windows.Foundation.UniversalApiContract (introduced v1)
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>
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 Extensible Application Markup Language (XAML) usage:
In order to support Extensible Application Markup Language (XAML) processor access to the attached properties, and also to expose equivalent get and set operations to code, each Extensible Application Markup Language (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 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.
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.
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.
|PlacementProperty PlacementProperty PlacementProperty PlacementProperty||
Identifies the ToolTipService.Placement XAML attached property.
|PlacementTargetProperty PlacementTargetProperty PlacementTargetProperty PlacementTargetProperty||
Identifies the ToolTipService.PlacementTarget XAML attached property.
|ToolTipProperty ToolTipProperty ToolTipProperty ToolTipProperty||
Identifies the ToolTipService.ToolTip XAML attached property.