Export (0) Print
Expand All
2 out of 7 rated this helpful - Rate this topic

ToolTip Class

Updated: February 2009

Represents a control that creates a pop-up window that displays information for an element in the interface.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
[LocalizabilityAttribute(LocalizationCategory.ToolTip)]
public class ToolTip : ContentControl
<ToolTip>
  Content
</ToolTip>

Content Model: ToolTip is a ContentControl. Its content property is Content. For more information on the content model for ToolTip, see Controls Content Model Overview.

You use a ToolTip control to provide information to the user. For example, you can use a ToolTip to provide the name of a Button or a ToolBar in a ToolBarTray. The content of a ToolTip control can vary from a simple text string to more complex content such as a StackPanel that has embedded text and images. The content of a ToolTip cannot receive focus.

A ToolTip control cannot have a parent. For example, you cannot set the Content property of a Button to a ToolTip Instead, assign a ToolTip to the FrameworkContentElement.ToolTip and FrameworkElement.ToolTip properties.

You can use a ToolTip on multiple elements by defining a ToolTip in a ResourceDictionary.

The properties of the ToolTip class are used to define the position and behavior of the tooltip. Many of these properties are also defined in the ToolTipService class. If the value of one of these properties is specified by both the ToolTip property and the ToolTipService attached property, the value of the ToolTipService property is used. In addition, the ToolTipService class provides properties to set timing behavior. These attached properties are not included in the ToolTip class but can be used by the control.

Dependency properties for this control might be set by the control’s default style. If a property is set by a default style, the property might change from its default value when the control appears in the application. The default style is determined by which desktop theme is used when the application is running. For more information, see Themes.

This example shows how to define a tooltip control for a TextBox element.

The following example shows how to define a tooltip by assigning text to the ToolTip property.

<TextBox HorizontalAlignment="Left">TextBox with ToolTip
  <TextBox.ToolTip>
    <TextBlock>Useful information goes here.</TextBlock>
  </TextBox.ToolTip>
</TextBox>

The following example shows how to define a tooltip by assigning a ToolTip object to the ToolTip property.

<TextBox HorizontalAlignment="Left">ToolTip with non-text content
  <TextBox.ToolTip>
    <ToolTip>
      <DockPanel Width="50" Height="70">
        <Image Source="data\flower.jpg"/>
        <TextBlock>Useful information goes here.</TextBlock>
      </DockPanel>
    </ToolTip>
  </TextBox.ToolTip>
</TextBox>

The following example uses code to generate a ToolTip object. The example creates a ToolTip (tt) and associates it with a Button.

button = new Button();
button.Content = "Hover over me.";
tt = new ToolTip();
tt.Content = "Created with C#";
button.ToolTip = tt;
cv2.Children.Add(button);

More Code

How to: Position a ToolTip This example shows how to specify the position of a tooltip on the screen.
How to: Delay the Display of a ToolTip This example shows how to set a ToolTipService property that causes a brief delay before a ToolTip displays. You set the properties of the ToolTipService class by attaching them directly to the element that exposes the tooltip.
How to: Use the BetweenShowDelay Property This example shows how to use the BetweenShowDelay time property so that tooltips appear quickly—with little or no delay—when a user moves the mouse pointer from one tooltip directly to another.
System.Object
  System.Windows.Threading.DispatcherObject
    System.Windows.DependencyObject
      System.Windows.Media.Visual
        System.Windows.UIElement
          System.Windows.FrameworkElement
            System.Windows.Controls.Control
              System.Windows.Controls.ContentControl
                System.Windows.Controls.ToolTip
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0

Date

History

Reason

February 2009

Described how default styles change dependency properties.

Customer feedback.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.