views:

644

answers:

2

how to validate the input form of a silverlight control? I have 3 controls, two out of three are text boxes (For name, and Age), and the remaining one control is date picker.

When i hit submit button, the validation should be invoked. how it will done??

thanks in advance.

+1  A: 

If you're using Silverlight 3 check out Data Validation. http://www.silverlightshow.net/items/Data-Validation-in-Silverlight-3.aspx

If you're using Silverlight 2 you'll have to roll your own code for validation.

Andy Britcliffe
A: 

I wrote my own validaion for SL2. It's based on:

  1. Attached property to give control custom validation ID
  2. Business object validators that identify invalid data
  3. VisualTreeHelper to parse visual tree and match validation result and custom validation ID
  4. Custom templates for controls in order to display validation
  5. INotifyPropertyChanged to remove validation display if property value was changed.
Nikolay R