--- title: "ToolTip Overview" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "ToolTip control [WPF], about ToolTip control" - "controls [WPF], ToolTip" ms.assetid: f06c1603-e9cb-4809-8a62-234607fc52f7 --- # ToolTip Overview A tooltip is a small pop-up window that appears when a user pauses the mouse pointer over an element, such as over a . This topic introduces the tooltip and discusses how to create and customize tooltip content. ## What Is a Tooltip When a user moves the mouse pointer over an element that has a tooltip, a window that contains tooltip content (for example, text content that describes the function of a control) appears for a specified amount of time. If the user moves the mouse pointer away from the control, the window disappears because the tooltip content cannot receive focus. The content of a tooltip can contain one or more lines of text, images, shapes, or other visual content. You define a tooltip for a control by setting one of the following properties to the tooltip content. - - Which property you use depends on whether the control that defines the tooltip inherits from the or class. ## Creating a ToolTip The following example shows how to create a simple tooltip by setting the property for a control to a text string. [!code-xaml[GroupBoxSnippet#ToolTipString](~/samples/snippets/csharp/VS_Snippets_Wpf/GroupBoxSnippet/CS/Window1.xaml#tooltipstring)] You can also define a tooltip as a object. The following example uses XAML to specify a object as the tooltip of a element. Note that the example specifies the by setting the property. [!code-xaml[ToolTipSimple#ToolTip](~/samples/snippets/csharp/VS_Snippets_Wpf/ToolTipSimple/CSharp/Pane1.xaml#tooltip)] The following example uses code to generate a object. The example creates a (`tt`) and associates it with a . [!code-csharp[ToolTipSimple#2](~/samples/snippets/csharp/VS_Snippets_Wpf/ToolTipSimple/CSharp/Pane1.xaml.cs#2)] [!code-vb[ToolTipSimple#2](~/samples/snippets/visualbasic/VS_Snippets_Wpf/ToolTipSimple/VisualBasic/Window1.xaml.vb#2)] You can also create tooltip content that is not defined as a object by enclosing the tooltip content in a layout element, such as a . The following example shows how to set the property of a to content that is enclosed in a control. [!code-xaml[GroupBoxSnippet#ToolTipDockPanel](~/samples/snippets/csharp/VS_Snippets_Wpf/GroupBoxSnippet/CS/Window1.xaml#tooltipdockpanel)] ## Using the Properties of the ToolTip and ToolTipService Classes You can customize tooltip content by setting visual properties and applying styles. If you define the tooltip content as a object, you can set the visual properties of the object. Otherwise, you must set equivalent attached properties on the class. For an example of how to set properties in order to specify the position of tooltip content by using the and properties, see [Position a ToolTip](how-to-position-a-tooltip.md). ## Styling a ToolTip You can style a by defining a custom . The following example defines a called `Simple` that shows how to offset the placement of the and change its appearance by setting the , , , and . [!code-xaml[ToolTipSimple#Style](~/samples/snippets/csharp/VS_Snippets_Wpf/ToolTipSimple/CSharp/Pane1.xaml#style)] ## Using the Time Interval Properties of ToolTipService The class provides the following properties for you to set tooltip display times: , , and . Use the and properties to specify a delay, typically brief, before a appears and also to specify how long a remains visible. For more information, see [How to: Delay the Display of a ToolTip](/previous-versions/dotnet/netframework-3.5/ms747264(v=vs.90)). The property determines if tooltips for different controls appear without an initial delay when you move the mouse pointer quickly between them. For more information about the property, see [Use the BetweenShowDelay Property](how-to-use-the-betweenshowdelay-property.md). The following example shows how to set these properties for a tooltip. [!code-xaml[ToolTipService#ToolTip](~/samples/snippets/csharp/VS_Snippets_Wpf/ToolTipService/CSharp/Pane1.xaml#tooltip)] ## See also - - - - - [How-to Topics](tooltip-how-to-topics.md)