- XAML Tutorial
- XAML - Home
- XAML - Overview
- XAML - Environment Setup
- Writing XAML Aplication On MAC OS
- XAML Vs C# Code
- XAML Vs.VB.NET
- XAML - Building Blocks
- XAML - Controls
- XAML - Layouts
- XAML - Event Handling
- XAML - Data Binding
- XAML - Markup Extensions
- XAML - Dependency Properties
- XAML - Resources
- XAML - Templates
- XAML - Styles
- XAML - Triggers
- XAML - Debugging
- XAML - Custom Controls
XAML - ToolTip
A ToolTip is a control that creates a pop-up window that displays information for an element in the GUI. The hierarchical inheritance of ToolTip class is as follows −
|Sr.No.||Property & Description|
Gets or sets a value that indicates whether the ToolTip is visible.
Identifies the IsOpen dependency property.
Gets or sets how a ToolTip is positioned in relation to the placement target element.
Identifies the Placement dependency property.
Gets or sets the visual element or control that the tool tip should be positioned in relation to when opened by the ToolTipService.
Identifies the PlacementTarget dependency property.
Gets an object that provides calculated values that can be referenced as TemplateBinding sources when defining templates for a ToolTip.
|Sr.No.||Event & Description|
Occurs when a ToolTip is closed and is no longer visible.
Occurs when a ToolTip becomes visible.
The following example shows the usage of ToolTip in an XAML application. Here is the XAML code in which a ToolTip is created with some properties to display ToolTip on Button and TextBlock.
<Window x:Class = "XAMLToolTip.MainWindow" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml" Title = "MainWindow" Height = "350" Width = "604"> <Grid> <StackPanel Orientation = "Vertical"> <Button Content = "Button with a simple ToolTip." ToolTipService.ToolTip = "Simple ToolTip" Width = "200" Margin = "50" /> <!-- A TextBlock with an offset ToolTip. --> <TextBlock Text = "TextBlock with an offset ToolTip." Width = "200" Margin = "50"> <ToolTipService.ToolTip> <ToolTip Content = "Offset ToolTip." HorizontalOffset = "20" VerticalOffset = "30"/> </ToolTipService.ToolTip> </TextBlock> </StackPanel> </Grid> </Window>
When the above code is compiled and executed with the ToolTip on Button and TextBlock, it will produce the following output −
We recommend you to execute the above example code and experiment with some other properties and events.
Kickstart Your Career
Get certified by completing the courseGet Started