Document.EndUpdate() Method
Unlocks the Rich Text Editor after a call to the BeginUpdate(Boolean) method and causes an immediate visual update.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v24.1.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
public void EndUpdate()
Remarks
Enclose your code in the BeginUpdate(Boolean) - EndUpdate
method calls to suppress the RichEdit’s visual updates and improve its performance when you make multiple changes to a document.
Each call to BeginUpdate(Boolean) should be paired with the EndUpdate call. The BeginUpdate(Boolean) method locks the component to prevent it from re-rendering after each modification. The EndUpdate
method unlocks the control to allow all the changes to be applied.
The following code snippet locks the Rich Text Editor until every paragraph in the main sub-document is updated.
<DxRichEdit @ref="richEdit" />
@code {
DxRichEdit richEdit;
protected override Task OnAfterRenderAsync(bool firstRender) {
if (firstRender)
InitializeDocument();
return base.OnAfterRenderAsync(firstRender);
}
async void 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 {
richEdit.DocumentAPI.BeginUpdate();
IReadOnlyList<Paragraph> paragraphs = await richEdit.DocumentAPI.Paragraphs.GetAllAsync();
foreach (Paragraph p in paragraphs)
await p.ChangePropertiesAsync(properties => {/*...*/});
richEdit.DocumentAPI.EndUpdate();
}
catch (OperationCanceledException e) {
Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
}
}
}