Home  /  Questions  /  Question



50   50
Nov 04, 2010


Silverlight 4 DataForm and INotifyDataErrorInfo

Hi,

I've spent some time testing and extending functionality of 'Silverlight Patterns 4.0 solution'.
I've been mainly struggling with populating validation errors on DataForm after raising ErrorsChanged event (INotifyDataErrorInfo interface).

Can you please give some suggestion or an example how to implement INotifyDataErrorInfo (in Silverlight) over DataForm with:
 - direct exposing Model to the View (CurrentCustomer property in your example) or
 - wrapping each Model property by ModelView property and exposing it to the View
and after raising ErrorsChanged event to display the validation error on DataForm?

 In the 'Silverlight Patterns 4.0 solution'  there is CustomerViewModel.CurrentCustomer property directly bound to the DataForm as CurrentItem of DataGridCustomers. The CurrentCustomer is directly exposing Customer model. In case we edit Customer details and after failed details validation how to display error on DataForm?
 
 During debugging after raising ErrorsChanged event I can see that the INotifyDataErrorInfo.GetErrors("CurrentCustomer") has been called by the external code (I suppose it is coming from DataForm as event subscriber) but there is no any error indication on DataForm.
 
 Thanks