tags:

views:

29

answers:

0

I try use IDataErrorInfo in WPF app on validation data, but if I try implement interface IDataErrorInfo in my class, I get this error:

'IDataErrorInfo' is a 'namespace' but is used like a 'type' I using namespace System.ComponentModel. Any advance.

code is here:

public partial class MainWindow : Window
    {
        public class Friend : IDataErrorInfo
        {
            private string _id;

            public string ID
            {
                get { return _id; }

                set { _id = value; }
            }

            private string _lastError;

            public string Error
            {
                get { return _lastError; }
            }

            string IDataErrorInfo.this[string propertyName]
            {
                get
                {
                    switch (propertyName)
                    {
                        case "ID": if (String.IsNullOrEmpty(ID))
                                _lastError = "Please insert a name!";
                            break;

                        default: _lastError = string.Empty;
                            break;

                    }
                    return _lastError;
                }
            }
        }

        public MainWindow()
        {
            InitializeComponent();
        }
    }
}