Javatpoint Logo
Javatpoint Logo

WPF ToolTip Control

Tooltip is a small pop-up window. We will see this window when the mouse is pause over the element. Like when the mouse is on the button.

Now we will discuss the ToolTip. What is Tooltip?

What is Tooltip?

When we move the mouse's pointer over the element, which is having the tooltip and the window, which contains the content of the tooltip, it appears for a definite time. If we move the pointer away from the control, then the window will disappear. This happens because the content of the tooltip doesn't receive the focus.

Content of the tooltip can contain one or more lines of the text, images, shapes, or other visual content.

We can define the tooltip for the control by setting the properties below to the tooltip's content.

  • ToolTip
  • ToolTip

Creation of Tooltip

Here we are going to take an example to show the creation of the tooltip by setting the property of the tooltip for the button control to the text string.

MainWindow.Xaml

The output of the above code will look like as shown in the below screenshot:

WPF ToolTip Control

In the above screen, we can see when we move the mouse over the button, which will show us a string of the text.

In the WPF, tooltip is not the type of the string. It is the type of the object, which means that we can put anything in the tooltip whatever we want.

Here we are going to take one more example and compares it with the above example.

MainWindow.XAML

The output of the above code will look like as shown in the below screenshot:

OUTPUT

WPF ToolTip Control

Here when we observe the above screenshot, we will see here we use the simple string tooltip in the first button. And on the second button we use the advanced string tooltip as shown in the below screenshot:

WPF ToolTip Control

Advanced Options

The properties of the Tooltipservice will affect the behavior of our tooltips. We can set these properties directly on the control, which contains the tooltip. For example, we can extend the time of the tooltip by using the ShowDuration Property. For this, we will write the below code:

We can also control the shadow of the content by using the HasDropShadow Property.

Wrap Up

The use of the tooltip is a great help for the user. WPF gives us the control that we can easily use and provides us with the flexibility to use the tooltip's content. With the use of the tooltip properties of the tooltipservice class, we can quickly create user-friendly applications.


Next Topic#




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA