Silverlight 5 Validation
This demo can also be accessed online here.
This example shows the following tricks when validating user input in Silverlight:
- MVVM with independent validation rules allowing for contextual validation with injection into view model via the constructor
- No validation is applied when first loading up the form
- Validation is applied when each control is updated, with form wide validation being applied when the user clicks the Ok button
- DatePicker control is loaded with no date and also prevents user textual input along with its validation
- Fluent Validation uses length, email and regex rules to validate properties
- View model implements INotifyPropertyChanged, INotifyDataErrorInfo and IEditableObject interfaces
- INotifyPropertyChanged and INotifyDataErrorInfo implementations are stored within an abstract view model base class
- Model implements bespoke generic ICloneable interface
- Cancel (by pressing escape) on grid reverts the data and controls back to original state
- RelayCommand has been used for the command buttons
Used to show if a field is required and/or any of other relevant info, when the user hovers over the little circle with the i for information to the right of the control.
Lists all validation errors on the grid and form.
Read more at #WINNING with C# – Silverlight 5 Validation