Back to Devexpress

Document.ChangeDefaultCharacterPropertiesAsync(Action<CharacterProperties>, CancellationToken) Method

blazor-devexpress-dot-blazor-dot-richedit-dot-document-dot-changedefaultcharacterpropertiesasync-x28-system-dot-action-devexpress-dot-blazor-dot-richedit-dot-characterproperties-system-dot-threading-dot-cancellationtoken-x29.md

latest3.3 KB
Original Source

Document.ChangeDefaultCharacterPropertiesAsync(Action<CharacterProperties>, CancellationToken) Method

Sets the default character formatting in the document.

Namespace : DevExpress.Blazor.RichEdit

Assembly : DevExpress.Blazor.RichEdit.v25.2.dll

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
public ValueTask ChangeDefaultCharacterPropertiesAsync(
    Action<CharacterProperties> modifier,
    CancellationToken cancellationToken = default(CancellationToken)
)

Parameters

NameTypeDescription
modifierAction<CharacterProperties>

A delegate method that configures default values of the character properties.

|

Optional Parameters

NameTypeDefaultDescription
cancellationTokenCancellationTokennull

An object that propagates a cancellation notification.

|

Returns

TypeDescription
ValueTask

A structure that stores an awaitable result of an asynchronous operation.

|

Remarks

Call the ChangeDefaultCharacterPropertiesAsync method to change an open document’s default character formatting. Refer to the following link for a list of all available format settings: CharacterProperties.

The following code snippet changes default font name and size of a document’s text once the document is loaded in the Rich Text Editor:

razor
<DxRichEdit DocumentLoaded=OnDocumentLoaded/>

@code {
    async Task OnDocumentLoaded(Document document) {
        await document.ChangeDefaultCharacterPropertiesAsync(properties => {
            properties.FontName = "Times New Roman";
            properties.FontSize = 12;
        });
    }
}

The Rich Text Editor applies the default character formatting to a text interval in the following cases:

To customize character properties of a text span, call its ChangePropertiesAsync method.

See Also

Document Class

Document Members

DevExpress.Blazor.RichEdit Namespace