New to Telerik UI for WPFStart a free 30-day trial

Change ToolTip ShowDuration

Updated on Sep 15, 2025

Environment

Product Version2022.1.117
ProductRadSyntaxEditor for WPF

Description

How to create a custom UILayer to customize the way that tooltips are shown such as extending their ShowDuration.

Solution

1. Implement a custom tooltip tagger as explained in the Custom Tagger article.

2. Implement a custom UILayer that derives from TextToolTipUILayer. In the GetLinePartUIElement method, you can get the Rectangle created by default and set the ToolTipService.ShowDuration attached property.

Creating a custom TextToolTipUILayer

C#
    public class CustomTextToolTipUILayer : TextToolTipUILayer
    {
        protected override FrameworkElement GetLinePartUIElement(ToolTipTag tag, Span span, UIUpdateContext updateContext)
        {
            var rectangle = (Rectangle)base.GetLinePartUIElement(tag, span, updateContext);
            ToolTipService.SetShowDuration(rectangle, int.MaxValue);
            return rectangle;
        }
    }

3. To apply the custom UILayer, create a custom UILayersBuilder and override its BuildUILayers method. In the method, you can replace the default TextToolTipUILayer with the custom one using the Remove and AddAfter methods of the UILayerStack.

Creating a custom UILayersBuilder

C#
    public class CustomUILayersBuilder : UILayersBuilder
    {
        public override void BuildUILayers(UILayerStack uiLayers)
        {
            base.BuildUILayers(uiLayers);
            uiLayers.Remove(PredefinedUILayers.TextToolTip);
            uiLayers.AddAfter(PredefinedUILayers.Text, new CustomTextToolTipUILayer());
        }
    }

4. Apply the custom UILayersBuilder using the syntax editor's property with the same name.

Creating a custom UILayersBuilder

C#
    this.syntaxEditor.UILayersBuilder = new CustomUILayersBuilder();

See Also