CharacterProperties Class
Contains character properties.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v24.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
public class CharacterProperties :
ICharacterProperties
Related API Members
The following members return CharacterProperties objects:
Remarks
Pass a CharacterProperties
object to the TextSpan.ChangePropertiesAsync method to set properties of all characters in a text span. You can customize individual character properties or call the CopyFrom(TextSpan) method to copy properties from another text span.
Pass a TableCellProperties object to the TableCell.ChangePropertiesAsync method to change table cell settings. The TableCellProperties.CharacterProperties setting allows you to change text formatting settings of a cell.
The following example copies character properties between two text spans:
<DxRichEdit @ref="richEdit" />
@code {
DxRichEdit richEdit;
Document documentAPI;
protected override async Task OnAfterRenderAsync(bool firstRender) {
if (firstRender)
try {
await InitializeDocument();
}
catch (TaskCanceledException) { }
await base.OnAfterRenderAsync(firstRender);
}
async Task InitializeDocument() {
/* Surround the code that contains an asynchronous operation with a try-catch block to handle
the OperationCanceledException. This exception is thrown when an asynchronous operation is canceled. */
try {
documentAPI = richEdit.DocumentAPI;
TextSpan characters = await documentAPI.AddTextAsync("New Text");
IReadOnlyList<Paragraph> paragraphs = await documentAPI.Paragraphs.GetAllAsync();
foreach (Paragraph p in paragraphs) {
TextSpan currentCharacters = await documentAPI.GetTextSpanAsync(p.Interval);
await currentCharacters.ChangePropertiesAsync(properties => {
properties.CopyFrom(characters);
});
}
}
catch (OperationCanceledException e) {
Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
}
}
}