I'm using RIA services with the MVVM pattern in Silverlight 4.
I've a page which displays a list of fields for the creation of a new object.
I've a Place entity and a GeneralInfo entity which is included in the Place entity using the Include in the property of the class and in the query to retrieve a place.
Everything is working fine, except the validation.
When I validate the Place entity before saving it, the validation is done only on the Place entity, but not the GeneralInfo entity.
There are different strange behavior:
If I simply let the fields empty, then only the fields of the Place entity have been validated and are marked in red.
If then I fill correctly the fields of the Place entity, then when I save it, I get an exception saying that I've to check the entitiesInError collection and then the fields of the GeneralInfo entity are marked in red if invalid.
An other case is if for a required field, for example, I enter some text and then delete it, then when I press Tab to leave the field and go to t开发者_如何学运维he next one, then the field is marked in red with the error message and it works also for the General Info entity fields.
What do I have to do to mark also the GeneralInfo entity fields in red when I validate the data?
Best regards, Daniel
The problem was not that I have an entity included in an other one. That's because TryValidateObject only performs "Required" validation. We have to set the last parameter to true to validate all validation types (Range Stringlength ...).
精彩评论