* net-current-v30plus-md.md * net-current-v40plus-md.md * tla2sharptla-ui-md.md * tla2sharptla-uiautomation-md.md * tla2sharptla-winclient-md.md * tla2sharptla-xaml-md.md * tlasharptla-ui-md.md * tlasharptla-uiautomation-md.md * tlasharptla-winclient-md.md * tlasharptla-xaml-md.md * fix warnings
5.2 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|
| How to: Position a ToolTip | 03/30/2017 |
|
|
cddf3757-9e5f-4ce3-a6eb-44489cf3804a |
How to: Position a ToolTip
This example shows how to specify the position of a tooltip on the screen.
Example
You can position a tooltip by using a set of five properties that are defined in both the xref:System.Windows.Controls.ToolTip and xref:System.Windows.Controls.ToolTipService classes. The following table shows these two sets of five properties and provides links to their reference documentation according to class.
Corresponding tooltip properties according to class
If you define the contents of a tooltip by using a xref:System.Windows.Controls.ToolTip object, you can use the properties of either class; however, the xref:System.Windows.Controls.ToolTipService properties take precedence. Use the xref:System.Windows.Controls.ToolTipService properties for tooltips that are not defined as xref:System.Windows.Controls.ToolTip objects.
The following illustrations show how to position a tooltip by using these properties. Although, the Extensible Application Markup Language (XAML) examples in these illustrations show how to set the properties that are defined by the xref:System.Windows.Controls.ToolTip class, the corresponding properties of the xref:System.Windows.Controls.ToolTipService class follow the same layout rules. For more information about the possible values for the Placement property, see Popup Placement Behavior.
The following image shows tooltip placement by using the Placement property:
The following image shows tooltip placement by using the Placement and PlacementRectangle properties:
The following image shows tooltip placement by using the Placement, PlacementRectangle, and Offset properties:
The following example shows how to use the xref:System.Windows.Controls.ToolTip properties to specify the position of a tooltip whose content is a xref:System.Windows.Controls.ToolTip object.
[!code-xamlToolTipService#ToolTip]
[!code-csharpToolTipService#ToolTipCode] [!code-vbToolTipService#ToolTipCode]
The following example shows how to use the xref:System.Windows.Controls.ToolTipService properties to specify the position of a tooltip whose content is not a xref:System.Windows.Controls.ToolTip object.
[!code-xamlToolTipService#NoToolTip]
[!code-csharpToolTipService#NoToolTipCode] [!code-vbToolTipService#NoToolTipCode]


