New to Telerik UI for WPF? Download free 30-day trial

Caret

The caret of the RadSyntaxEditor is the vertical "blinking" line that represents the current cursor position of a control that accepts text input. The appearance of the caret can be controlled by the CaretDisplayMode property. Its possible values as well as the resulting appearance can be observed in the following list:

  • Normal: RadSyntaxEditor caret normal display mode

  • Block: RadSyntaxEditor caret normal display mode

  • HalfBlock: RadSyntaxEditor caret normal display mode

  • QuarterBlock: RadSyntaxEditor caret normal display mode

Example 1: Setting the caret's display mode

<telerik:RadSyntaxEditor CaretDisplayMode="QuarterBlock" /> 

Hide the Caret

If you wish to hide the caret, you can do so by setting the IsCaretVisible property to False. This setting can be used along with the IsReadOnly property which disallows users from making changes in the editor.

Example 2: Setting the caret's display mode

<telerik:RadSyntaxEditor IsReadOnly="True" IsCaretVisible="False" /> 

Caret Brush

Through the CaretBrush property, you can change the caret's color to a color of your liking. The default value is Black.

Example 3: Setting the caret's color

<telerik:RadSyntaxEditor CaretBrush="Red" /> 

Figure 1: RadSyntaxEditor caret with red color

RadSyntaxEditor caret with red color

Auto-Scroll to Caret on Text Change

With the R1 2021 release, the RadSyntaxEditor exposes the AutoScrollToCaretOnTextChange property which controls whether the document is automatically scrolled to the CaretPosition when the text inside the document is changed.

Its default value is True, meaning that if the caret is placed in the end of the document, for example, and new text is added, the control will auto-scroll to the new position of the caret when the content changes.

To disable this behavior, you can set the AutoScrollToCaretOnTextChange property to False.

Example 4: Setting the AutoScrollToCaretOnTextChange property

<telerik:RadSyntaxEditor AutoScrollToCaretOnTextChange="False" /> 

See Also

In this article
Not finding the help you need? Improve this article