1
votes

Im developing a solution in Silverlight 4 with RIA Services. I am using data annotations on my entity to describe validation. I can see these are reflected on the client side code after building. I have a child window which has textboxes bound to a single entity record for editing. The data annotation i have on all the textboxes is the annotation but this does not ever fire until a user has editted a textbox first, left the textbox, re-entered the textbox and then deletes the content. This has no use if i am trying to force someone to fill in a textbox as they may skip straight over the textbox with the required data annotation.

Am i missing something simple here?

Thanks in advance

1
When should it fire, then? If you want to force someone to fill textboxes, you can check whether the object is valid after the button is pressed.vortexwolf
How do you test it? On my submit i am testing if the child window Entity.HasValidationErrors which returns false which i would expect to return true when a RequiredField is not populated.Oly
You should call validation methods explicitly. There are 2 of them: Validator.TryValidateObject and Validator.ValidateProperty. Also set the ValidatesOnExceptions property to true at binding.vortexwolf

1 Answers

0
votes

I have been using this very effective solution without any issues in both SL3, 4 and 5, thanks to Thomas Claudius Huber: http://www.thomasclaudiushuber.com/blog/2009/07/17/here-it-is-the-updatesourcetrigger-for-propertychanged-in-silverlight/