All docs
V21.1
21.2 (EAP/Beta)
21.1
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

ValidationArgs.UseCancellationToken Property

Gets or sets whether changes made within a row can be canceled.

Namespace: DevExpress.Mvvm.Xpf

Assembly: DevExpress.Mvvm.v21.1.dll

Declaration

public bool UseCancellationToken { get; set; }

Property Value

Type Description
Boolean

true if changes made within a row can be canceled; otherwise, false.

Remarks

If you want to update a row asynchronously, create a command and bind it to the ValidateRowCommand or 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);
}
See Also