Back to Devexpress

Document.GetIsEmptyAsync(CancellationToken) Method

blazor-devexpress-dot-blazor-dot-richedit-dot-document-dot-getisemptyasync-x28-system-dot-threading-dot-cancellationtoken-x29.md

latest2.0 KB
Original Source

Document.GetIsEmptyAsync(CancellationToken) Method

Returns whether the document is empty.

Namespace : DevExpress.Blazor.RichEdit

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

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

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

Optional Parameters

NameTypeDefaultDescription
cancellationTokenCancellationTokennull

An object that propagates a cancellation notification.

|

Returns

TypeDescription
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

Document Class

Document Members

DevExpress.Blazor.RichEdit Namespace