Skip to main content
All docs
V24.1

ValidationArgs.ResultAsync Property

Gets or sets a task that asynchronously posts changes to an underlying data source (database).

Namespace: DevExpress.Mvvm.Xpf

Assembly: DevExpress.Mvvm.v24.1.dll

NuGet Packages: DevExpress.Mvvm, DevExpress.Win.Navigation

Declaration

public Task<ValidationErrorInfo> ResultAsync { get; set; }

Property Value

Type Description
Task<ValidationErrorInfo>

A task that asynchronously posts changes to an underlying data source (database).

Remarks

If you want to update a row asynchronously, create a command and bind it to the ValidateRowCommand or ValidateNodeCommand property.

Use the ResultAsync property to specify a task that asynchronously posts changes to an underlying data source (database).

You can also validate data and specify an error description. If the data are invalid, the task should return the ValidationErrorInfo object; otherwise, return null.

To allow a user to cancel changes, set the UseCancellationToken property to true and use the CancellationToken in a cancel function.

[Command]
public void UpdateIssue(RowValidationArgs args) {
    args.UseCancellationToken = true;
    args.ResultAsync = UpdateIssueAsync(args.Item as IssueData, args.CancellationToken);
}
static async Task<ValidationErrorInfo> UpdateIssueAsync(IssueData issue, CancellationToken token) {
    if(!IssuesService.ServerIsConnected)
        return new ValidationErrorInfo("Server is disconnected.", ValidationErrorType.Critical);
    await IssuesService.UpdateRowAsync(issue, token);
    return null;
} 

public async static System.Threading.Tasks.Task UpdateRowAsync(IssueData row, CancellationToken token) {
    if(row == null)
        return;
    IssueData data = null;
    for(int i = 0; i < AllIssues.Value.Length; i++) {
        if(token.IsCancellationRequested)
            return;
        if(AllIssues.Value[i].Id == row.Id)
            data = AllIssues.Value[i];
    }
    if(data == null)
        return;
    data.Priority = row.Priority;
    data.Subject = row.Subject;
    data.UserId = row.UserId;
    data.Votes = row.Votes;
    data.Created = row.Created;
    await System.Threading.Tasks.Task.Delay(500).ConfigureAwait(false);
}

Limitation

Async validation for cells is not supported. The GridControl throws an exception if you specify the ResultAsync property in the command bound to the GridViewBase.ValidateCellCommand property.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ResultAsync property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also