Skip to main content
A newer version of this page is available. .
All docs
V21.1

GridViewBase.ValidateRowCommand Property

Gets or sets a command that validates row values.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v21.1.dll

NuGet Package: DevExpress.Wpf.Grid.Core

Declaration

public ICommand<RowValidationArgs> ValidateRowCommand { get; set; }

Property Value

Type Description
DevExpress.Mvvm.ICommand<RowValidationArgs>

A command that validates row values.

Remarks

Bind a command to the ValidateRowCommand property to maintain a clean MVVM pattern. The command works like a ValidateRow event handler and allows you to process the row validate operation in a View Model.

The Item property returns a data item within the processed row.

The code sample below verifies if data meet the validation criteria. Use the Result property to specify the validation message.

[Command]
public void ValidateRow(RowValidationArgs args) {
    args.Result = GetValidationErrorInfo((Task)args.Item);
}
static ValidationErrorInfo GetValidationErrorInfo(Task task) {
    if(task.StartDate > task.EndDate)
        return new ValidationErrorInfo("StartDate must be less than EndDate");
    if(string.IsNullOrEmpty(task.TaskName) || string.IsNullOrWhiteSpace(task.TaskName))
        return new ValidationErrorInfo("Task name hasn't been entered");
    return null;
} 

You can also invoke the CommitEditing method to validate changes.

Refer to the following topic for more information: Row Validation.

Use the ResultAsync property to validate row data asynchronously.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ValidateRowCommand 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