---
title: "Input Validation and UI Exceptions with MVVM Light"  
description: "Input Validation and UI Exceptions with MVVM Light"  
author: "Anonymous User"  
published: 2013-07-19  
updated: 2013-07-19  
canonical: https://www.mindstick.com/forum/1335/input-validation-and-ui-exceptions-with-mvvm-light  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# Input Validation and UI Exceptions with MVVM Light

I am using MVVM using GalaSoft light [Framework](https://www.mindstick.com/forum/34615/software-framework-vs-library)(mvvmlight(wpf4)). I have problems Validating Data [input from the user](https://www.mindstick.com/forum/158952/what-are-the-different-methods-for-reading-input-from-the-user-in-python) and Displaying MessageBox indicating empty/incorrect input from the user,I wanted to use INotifyDataErrorInfo and this [article](https://www.mindstick.com/articles/95867/are-you-looking-for-500-credit-score-mortgage-lenders-houston-continue-reading-this-article) , but don't [support](https://yourviews.mindstick.com/view/286/modi-support-for-sportsperson) 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](https://www.mindstick.com/forum/158627/describe-the-concept-of-an-httprequestvalidationexception-and-its-relevance-in-input-validation) in mvvm light ?(send a [message](https://www.mindstick.com/forum/12802/show-confirmation-message-yes-or-no-in-asp-dot-net) from save [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) to the [ViewModel](https://www.mindstick.com/forum/157215/what-is-viewmodel-in-mvc) to [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) the input values.)

## Replies

### Reply by Vijay Shukla

You can send message on button.click event like this..

Messenger.Default.Send<string>("showattraction", "attraction");

first string is message and other is token for varifying it..

and where you recive this message do this..in constructor..

essenger.Default.Register<string[]>(this, "attraction", GetLineDetails);

do your work in GetLineDetails method..

public void GetLineDetails(string[] Message)

{

// work here...

}


---

Original Source: https://www.mindstick.com/forum/1335/input-validation-and-ui-exceptions-with-mvvm-light

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
