Print Page | Close Window

Silverlight 4 Verification

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1836
Printed Date: 21-Apr-2026 at 12:20pm


Topic: Silverlight 4 Verification
Posted By: Vincent
Subject: Silverlight 4 Verification
Date Posted: 21-May-2010 at 6:21am
I am having a problem on how to propagate error messages onto the silverlight 4 UI during verification. Can anyone help me please.



Replies:
Posted By: IdeaBlade
Date Posted: 21-May-2010 at 8:28am
What controls are you using?  DataForm and DataGrid respect the INotifyDataErrorInfo interface described below (and implemented by DevForce-generated Entities), and should respond automatically. I'm not sure about the state of other Silverlight controls - please check Microsoft docs.


Verification in the Silverlight UI

System.ComponentModel.INotifyDataErrorInfo is a Silverlight-only interface that defines members that data entity classes can implement to provide custom, asynchonous validation support. Important Silverlight user interface controls including the DataForm and DataGrid check for the implementation of this interface by data entities to which they are bound and provide excellent messaging in the user interface to help end users learn about and correct validation errors.

Such Silverlight user interface controls do not depend upon exceptions being thrown in order to learn about validation problems. Instead, they subscribe to an ErrorChanged event published by the entity as part of its INotifyDataErrorInfo compliance. That event is raised by the data entity whenever it believes that a change to its state might be important to some control in the user interface. The UI control, learning of such a change, can then query the data entity via its INotifyDataErrorInfo.GetErrors() method to obtain a current set of validation errors, which it may then expose to the end user as its developer sees fit.

Because of the support for INotifyDataErrorInfo by Silverlight UI controls, most developers working in Silverlight will want to set the system default for VerifierOptions.ErrorNotificationMode to Notify rather than any setting that results in exceptions being thrown for validation errors.




Posted By: Vincent
Date Posted: 21-May-2010 at 9:16pm
Thank you for the reply
 
Using the DataForm, I changed the VerifierOptions.ErrorNotificationMode to Notify and it has worked but only with editing. When I create new entity, it does not verify.


Posted By: IdeaBlade
Date Posted: 24-May-2010 at 6:29pm
After creating the new Entity, are you adding it to the EntityManager?


Posted By: Vincent
Date Posted: 24-May-2010 at 8:08pm
Yes. After creating a new entity I add it to the entity manager and then set the datacontext property of the dataform to the entity.



Print Page | Close Window