Represents a control that creates a pop-up window that displays information for an element in the interface.
[System.Windows.Localizability(System.Windows.LocalizationCategory.ToolTip)] public class ToolTip : System.Windows.Controls.ContentControl
The following examples 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>
<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>
button = new Button(); button.Content = "Hover over me."; tt = new ToolTip(); tt.Content = "Created with C#"; button.ToolTip = tt; cv2.Children.Add(button);
button = New Button() button.Content = "Hover over me." tt = New ToolTip() tt.Content = "Created with Visual Basic" button.ToolTip = tt cv2.Children.Add(button)
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.
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.
Customizing the ToolTip Control
To apply the same property settings to multiple ToolTip controls, use the Style property. You can modify the default ControlTemplate to give the control a unique appearance. For more information about creating a ControlTemplate, see Customizing the Appearance of an Existing Control by Creating a ControlTemplate. To see the parts and states that are specific to the ToolTip, see ToolTip Styles and Templates.
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 Default WPF Themes.
Setting a visual property will only have an effect if that property is both present in ToolTip control's default template and is set by using a . You can find a list of visual properties in the "Changing the Visual Structure of a Control" section in Customizing the Appearance of an Existing Control by Creating a ControlTemplate.
Initializes a new instance of the ToolTip class.
Identifies the Closed routed event.
Identifies the CustomPopupPlacementCallback dependency property.
Identifies the HasDropShadow dependency property.
Identifies the HorizontalOffset dependency property.
Identifies the IsOpen dependency property.
Identifies the Opened routed event.
Identifies the Placement dependency property.
Identifies the PlacementRectangle dependency property.
Identifies the PlacementTarget dependency property.
Identifies the StaysOpen dependency property.
Identifies the VerticalOffset dependency property.
Gets or sets the delegate handler method to use to position the ToolTip.
Gets or sets a value that indicates whether the control has a drop shadow.
Get or sets the horizontal distance between the target origin and the popup alignment point.
Gets or sets a value that indicates whether a ToolTip is visible.
Gets or sets the rectangular area relative to which the ToolTip control is positioned when it opens.
Get or sets the vertical distance between the target origin and the popup alignment point.
Responds to the Closed event.
Called when the Content property changes.
Responds to the Opened event.
Responds to a change in the visual parent of a ToolTip.
Occurs when a ToolTip is closed and is no longer visible.
Occurs when a ToolTip becomes visible.