forum

Home / DeveloperSection / Forums / Input Validation and UI Exceptions with MVVM Light

Input Validation and UI Exceptions with MVVM Light

Anonymous User 5234 19-Jul-2013

I am using MVVM using GalaSoft light Framework(mvvmlight(wpf4)). I have problems Validating Data input from the user and Displaying MessageBox indicating empty/incorrect input from the user,I wanted to use INotifyDataErrorInfo and this article , but don't support in wpf4.

private string _password;
    private string _userName;
    [Required(AllowEmptyStrings = false, ErrorMessage = "Username is required")]
    public string UserName
    {
        get { return _userName; }
        set
        {
            if (_userName != value)
            {
                //  ValidateProperty("UserName", value);
                _userName = value;
                base.RaisePropertyChanged("UserName");
            }
        }
    }
    [Required(AllowEmptyStrings = false, ErrorMessage = "Password is required")]
    public string Password
    {
        get { return _password; }
        set
        {
            if (_password != value)
            {
                //  ValidateProperty("Password", value);
                _password = value;
                base.RaisePropertyChanged("Password");
            }
        }
    }

How to use Messanger for input validation in mvvm light ?(send a message from save button to the ViewModel to check the input values.)


wpf wpf 
Updated on 19-Jul-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By