Apologies for the cross-posts (I asked this at the Silverlight Forum , but received no reply)
I have an entity that I am trying to use for verification, so I decorated this property:
[Required]
[StringLength(10)]
public string Code
{
get
{
return this.code;
}
set
{
if (this.code != value)
{
this.code = value;
this.SendPropertyChanged("Code");
}
}
}
I have a list of these gridded objects. If I put an empty entry, it shows a validation error. If I add code too long, I get a validation error. Fine! With the exception of...
I want the user to not be able to save the object, so I added the following to my object:
public bool IsValid()
{
try
{
this.Validate();
}
catch
{
return false;
}
return true;
}
public void Validate()
{
var ctx = new ValidationContext(this, null, null);
Validator.ValidateObject(this, ctx);
}
, IsValid false.
( , ), StringLength ( ).
:
http://walkersretreat.co.nz/files/Slvalidation.zip
- ?
!