Skip to main content

IDataErrorInfoHelper Class

Provides extension methods to get an error based on defined DataAnnotation attributes or Fluent API

Namespace: DevExpress.Mvvm

Assembly: DevExpress.Mvvm.v22.1.dll


public static class IDataErrorInfoHelper


The following code sample enables validation for TextEdit controls. If they contain valid text, the Save button is enabled:

        <dxmvvm:BooleanNegationConverter x:Key="BooleanNegationConverter"/>
        <dxmvvm:ValidationErrorsHostBehavior x:Name="validationErrorsHostBehavior"/>
        <StackPanel Orientation="Vertical" ...>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="First Name: " .../>
                <dxe:TextEdit Text="{Binding FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, 
                                NotifyOnValidationError=True, ValidatesOnDataErrors=True}" .../>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Last Name: " .../>
                <dxe:TextEdit Text="{Binding LastName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, 
                                NotifyOnValidationError=True, ValidatesOnDataErrors=True}" .../>
            <Button Content="Login" ... IsEnabled="{Binding ElementName=validationErrorsHostBehavior, 
                                                   Path=HasErrors, Converter={StaticResource BooleanNegationConverter}}"/>
using DevExpress.Mvvm;
using System.ComponentModel;

namespace Example.ViewModel {
    public class MainViewModel : ViewModelBase, IDataErrorInfo {
        public string FirstName {
            get { return GetValue<string>(); }
            set { SetValue(value); }

        public string LastName {
            get { return GetValue<string>(); }
            set { SetValue(value); }

        public string Error {
            get {
                return this["FirstName"] != null || this["LastName"] != null ? "Invalid values." : null;

        public string this[string columnName] {
            get {
                switch (columnName) {
                    case "FirstName":
                        return string.IsNullOrEmpty(FirstName) ? "First Name cannot be empty." : null;
                    case "LastName":
                        return string.IsNullOrEmpty(LastName) ? "Last Name cannot be empty." : null;
                        return null;


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


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