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

Customizing the Document Content of Sdt Element in RadRichTextBox

Updated on Mar 31, 2026

Environment

ProductRadRichTextBox for UI for WPF
Version2026.1.211

Description

How to customize or replace the document content of a content control (structured document tag) in RadRichTextBox for WPF.

Solution

To replace or customize the default DocumentFragment that is created for a Sdt element (like DateProperties or CheckBoxProperties), the content builder of the associated SdtProperties class can be overridden. To do this, override the GetBuilder method of the properties class. Then. you can create a custom SdtContentGenerator and use it in the GetBuilder method override.

C#
  public class CustomDateProperties : DateProperties
  {
      protected override ISdtBuilder GetBuilder(SdtRangeStart associatedSdt)
      {
          var builder = base.GetBuilder(associatedSdt);
          typeof(SdtDateBuilder)
              .GetField("contentGenerator", BindingFlags.NonPublic | BindingFlags.Instance)
              .SetValue(builder, new CustomSdtDateContentGenerator(this));
          return builder;
      }
  }

  public class CustomSdtDateContentGenerator : SdtDateContentGenerator
  {
      public CustomSdtDateContentGenerator(DateProperties properties) : base(properties)
      {
      }

      public override DocumentFragment GetContentFragmentOverride()
      {
          var fragment = base.GetContentFragmentOverride();
          var span = fragment.EnumerateChildrenOfType<Span>().FirstOrDefault();
          if (span != null)
          {
               //adjust the span font settings
          }
          return fragment;
      }
  }
In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support