Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Document.GetIsEmptyAsync(CancellationToken) Method

Returns whether the document is empty.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
public ValueTask<bool> GetIsEmptyAsync(
    CancellationToken cancellationToken = default(CancellationToken)
)

#Optional Parameters

Name Type Default Description
cancellationToken CancellationToken null

An object that propagates a cancellation notification.

#Returns

Type Description
ValueTask<Boolean>

A structure that stores an awaitable result of an asynchronous operation. The awaitable result is a value that indicates whether the document is empty.

#Remarks

A document is empty if it contains only an empty main sub-document. If a document contains an empty header, footer, or text box, the GetIsEmptyAsync method returns false.

The following code snippet creates a new document if an open document is not empty:

Razor
<DxRichEdit @ref="@richEdit" />

@code {
    DxRichEdit richEdit { get; set; }

    async void CreateNewDocument() {
        bool isEmpty = await richEdit.DocumentAPI.GetIsEmptyAsync();
        if (!isEmpty)
            await richEdit.NewDocumentAsync();
    }
}
See Also