With the latest improvements in our RichTextBox for WPF, you can add specific semantics such as restricting input, modifying editing behavior, etc. to a document. Check out how it works.
With the R2 2020 release, Telerik UI for WPF gained Content Controls for RichTextBox that enable end-users to easily add specific semantics such as restricting input, modifying editing behavior, etc. to parts of a given document. In this blog post, we will walk you through the features and functionalities of the Content Controls.
Structured Document Tags vs. Content Controls
First, let us clarify an important distinction between structured document tags and content controls. Structured document tags are XML elements (tags) defined in the WordprocessingML that allow embedding customer-defined semantics as well as their behavior and appearance into a document. The visual representation (UI) of these elements we refer to as Content Controls. The Structured document tags have content and pre-defined properties, and these properties set the semantic specifics, and according to them the RadRichTextBox decides which Content Control to visualize.
For better understanding: Consider a region which should be tagged with the semantic of "birthday," for the user to enter their date of birth into the document. Ideally, this region would also utilize a date picker to allow the user to enter the date from a calendar:
This content would be specified by using Structured Document Tags properties and visualized (according to these properties) as Content Controls in the document.
What are the Content Controls?
Content controls are individual controls that can be used inside forms, templates and documents in order to further improve the user experience. They enable users to restrict input, modify editing behavior, etc. Content controls can be defined on Block, Inline, Row or Cell level, and can be nested inside each other. You can manipulate existing or insert new content controls.
When & Why We Need Content Controls
Content controls provide a way to design documents and templates by:
- Controlling the input from the UI.
For example, if you need the user to choose from a list of choices in a document section, you can add a Drop-Down List content control to the document with the predefined options.
- Preventing users from editing protected areas.
The content controls provide the option to restrict the area inside the content control by using its locking properties, which you can see later in the Fine Mechanics section. If the area is not inside the content control or you want to restrict an area accommodating content controls and other types of content, you can put the whole area in a Group content control or in a Rich Text content control and set its locking properties.
Working with Content Controls
When you have the RadRichTextBox control open, you can choose among the supported content control types inside the Developer Tab.
Supported Content Controls Types
As of R2 2020 there are eight content control types that can be inserted using the user interface (UI) or the RadRichTextBox API:
- Rich Text content control: This content control represents a block of rich text, where you can contain formatted text or other items (e.g. pictures, tables or even other content controls). It is the least restrictive content control and can contain more or less anything.
- Plain Text content control: It represents a block of plain text. Its content can only consist of a single paragraph or table cell.
- Picture content control: It can be used inside templates. It adds an image placeholder which can later be edited to contain a picture in a template.
- Repeating Section content control: It contains at least one whole paragraph of text (Repeating Section Item) that can be repeated several times.
- Check Box content control: The content control can be used to represent a binary choice. The default values are “checked” and “unchecked,” but it can contain any pair of symbols defined in any font installed on the current machine.
- Combo Box content control: In a combo box, you can select an item from a list of choices, or you can provide your own custom text.
- Drop-Down List content control: Unlike the combo box, the contents of a drop-down list should be one of the pre-defined choices.
- Date Picker content control: It can be used in a template or form to indicate that a valid date should be entered.
RadRichTextBox supports import/export and basic operations for the following content controls as well using its API:
- Group content control
- Citation content control
- Bibliography content control
- Document Part content control
- Document Part Gallery content control
- Equation content control
- Repeating Section Item content control
Content Controls expose a bunch of properties that can be modified both directly from the UI or programmatically.
- This example shows how to use the RadRichTextBox UI to Lock (restrict from editing and deleting) the Picture content control and how to change the Language format and DateFormat of the Date Picker content control:
- This example demonstrates the same functionality but programmatically:
PictureProperties pictureProperties = new PictureProperties();
pictureProperties.Lock = Lock.SdtContentLocked;
DateProperties dateProperties = new DateProperties();
dateProperties.Language = new CultureInfo("bg-BG");
dateProperties.DateFormat = "dd MMMM yyyy 'г.'";
dateProperties.FullDate = new DateTime(2020, 5, 13);
Try Content Controls Yourself
Get yourself a free trial of Telerik UI for WPF today and start developing your apps better, faster and more easily.
Check Out Telerik UI for WPF
Share Your Feedback
Let’s continue to build the future of Telerik UI for WPF together! So don’t forget to share your thoughts as a comment below or let us know if you have any suggestions and/or need any features/controls by visiting our Feedback portals about UI for WPF/Silverlight and Document Processing Libraries.