How to set the ToolTip for the WPF control?
The ScreenTip is an advanced ToolTip control, which UI element appears like a small window with Header, footer and content when the mouse cursor is hovered over an associated control. The ScreenTip is derived from the ToolTip which contain the following property such as:
- Description
- HelpIcon
- HelpText
- ImageSource
Description:
Get or set the ScreenTip description.
HelpIcon:
Get or set the image for HelpIcon.
HelpText:
Get or set the Text for ScreenTip.
ImageSource:
Get or set the Image that appears in ScreenTip.
Content:
Get or set the content of a content control.
Using the above property, we can set the tooltip in different sections.
The following is an example that shows how the ScreenTip used as a ToolTip for the ButtonAdv control. Please find the following code example below:
XAML:
<Window x:Class="ButtonAdvSample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:ButtonAdvSample" xmlns:syncufsion="http://schemas.syncfusion.com/wpf" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> <Grid> <syncufsion:ButtonAdv VerticalAlignment="Center" x:Name="buttonadv" HorizontalAlignment="Center"/> </Grid> </Window>
C#:
ScreenTip sc = new ScreenTip(); sc.ImageSource =new BitmapImage(new Uri(@"/ButtonAdv_I126747;component/Images/CameraImage.png", UriKind.Relative)); sc.HelpText = "Used to take the photos"; sc.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom; sc.Width = 240; sc.Content = "Tap here to capture the photos"; sc.Description = "ScreenTip for ButtonAdv control"; ButtonAdv.ToolTip = sc;
Fig 1: The screenshot shows the screentip applied for the tooltip of ButtonAdv control
Sample Links:
C#: How to use ToolTip in WPF Control C#