Articles in this section
Category / Section

How to customize the style of tooltip in WPF RichTextBox (SfRichTextBoxAdv) control?

1 min read

You can customize the visual appearance of a tooltip in the WPF RichTextBox (SfRichTextBoxAdv) control by defining a custom style for the ToolTip control based on your requirements.

The following code example demonstrates the custom style definition for the ToolTip control.

XAML

<!-- Defines the custom style for the tooltip. -->
<Style x:Key="ToolTipStyle" TargetType="{x:Type ToolTip}">
    <Setter Property="OverridesDefaultStyle" Value="True"/>
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="BorderBrush" Value="#2D2D2D"/>
    <Setter Property="Background" Value="#000000" />
    <Setter Property="Foreground" Value="#FFFFFF"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ToolTip}">
                <Border x:Name="Root" CornerRadius="2" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                    <ContentPresenter Margin="2" HorizontalAlignment="Center" VerticalAlignment="Top"/>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsOpen" Value="False">
                        <Setter TargetName="Root" Property="Visibility" Value="Collapsed"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
 
<!-- Defines the customized tooltip. -->
<ToolTip x:Key="CustomToolTip" Style="{StaticResource ToolTipStyle}"/>

The following code example demonstrates how to use the customized tooltip in the SfRichTextBoxAdv control.

<!-- SfRichTextBoxAdv control with customized tooltip. -->
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv" ToolTip="{StaticResource CustomToolTip}" xmlns:RichTextBoxAdv="clr-namespace:Syncfusion.Windows.Controls.RichTextBoxAdv;assembly=Syncfusion.SfRichTextBoxAdv.Wpf"/>

Customize Tooltip in WPF RichTextBox

View the sample in GitHub.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied