Data validation in silverlight
Upcoming SlideShare
Loading in...5

Like this? Share it with your network

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 381 380 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Validation Errors
    Senior Software Engineer
    United Health Group
  • 2. Mahender Sarangam
    Having 5 years of experience on .NET Technologies. Working as a Senior Software Engineer in United Health Group (UHG India Information Service Ltd.). Worked with Big Firms like Deloitte Consulting & Wipro Technology.
    Got Technical Acquaintance on Technologies like C#, ASP.NET,AJAX, LINQ, Silverlight, WPF,WCF ,SQL Server, Team Foundation Server(TFS) and SharePoint Technology.
    MCTS Certified in Web Technologies.
    Blog :
  • 3. What are Validation Errors?
    • Silverlight provides several ways to validate data. The
    simplest and oldest approach is to use exception-based
    • In Silverlight 3 , Validation is performed using
    “ValidationOnException” property in Binding expression
    to throw validate errors .
    • Incorrect data type: For example, a numeric property like UnitCost can’t accommodate letters or special characters. Similarly, it can’t hold extremely large numbers (numbers larger than 1.79769313486231570E+308).
    • 4. Property setter exception: For example, a property like UnitCost may use a range check and throw an exception if you attempt to set a negative number.
    • 5. Read-only property: This can’t be set at all.
  • 6. To enable the BindingValidationFailed event, you must set ValidatesOnExceptionsto true (to detect errors) and NotifyOnValidationError to true (to fire the validation events). Whenever NotifyOnValidationError is true, BindingValidationError is fired and its bubble event,which can be handled in parent elements.
    For example :
    <TextBoxMargin="5" Grid.Row="2" Grid.Column="1" x:Name="txtUnitCost” Text="{Binding UnitCost, Mode=TwoWay, ValidatesOnExceptions=True,
  • 7. Steps for Data Object Validation
    There are three basic steps to follow
    Implement the IDataErrorInfo or INotifyDataErrorInfo interface in your data object.
    Tell the data binding infrastructure to check the data object for errors and show error notifications. If you’re using the IDataErrorInfo interface, you set ValidatesOnDataErrors to true. If you’re using the INotifyDataErrorInfo interface, you set ValidatesOnNotifyDataErrorsto true
    Optionally, set NotifyOnValidationError to true if you want to receive the BindingValidationFailedevent.
    Optionally, set the ValidatesOnExceptions property to true if you want to catch other types of errors, such as data conversion problems.
    private <string, <string>> errors = new <string, List<string>>();
    public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
  • 8. Thank you