I have a Silverlight form that performs exception-based data validation. I learned how to do this data validation the following way:
Set controls to be validated as follows:
<TextBox Text="{Binding Mode=TwoWay,NotifyOnValidationError=True, Source={StaticResource docSan}, Path= metadati.paziente.residenza, ValidatesOnExceptions=True}"/>
Make the target property work as follows
public new string residenza
{
get { return base.residenza; }
set
{
if (string.IsNullOrEmpty(value)) throw new ArgumentNullException("value");
base.residenza = value;
}
}
Where the base class defines a non-validating property in an INotifyPropertyChanged
way
Unfortunately VS2010 at design time warns me about the exception for each text box. This doesn't prevent the application from running (it works fine) but it's just annoying.
Somebody knows how to tell VS that it's OK if at design time no value is specified thus the code throws naturally?