10 Answers, 1 is accepted
I am sending you a sample project illustrating a basic validation of the RadDataForm. You may test the case by inserting a string into the Salary field and the validation error will be displayed.
Let me know in case your scenario is not the same and if so, please provide more information about your requirements.
Maya
the Telerik team

That's not exactly what I wanted, since I'm using Entity Framework, the classes already implement INotifyPropertyChanged. However the kind of validation I wish to implement is more of a business logic kind of validation. For example "Username not available" or "Name cannot be left empty".
Many Thanks,
Daryl
I am sending you an updated version of the sample illustrating how you may implement custom logic for validating the values. Furthermore, you may handle the ValidatingItem event, perform your own validation and cancel the default one.
Maya
the Telerik team

Also, I am trying to understand why we need DataForm[XXX]Field controls if I am not changing the layout of the form. In my mind, the RadDataForm control should handle data type validations (w/o any extra code) and business rules validations. Now on this last one, if we implement these business rules validations inside the property setter (by throwing an exception), how do we catch it?
Validation Example Page
The first issue you mentioned is a validation handled by the Framework, not by the data form. You are not allowed to enter string values into numeric fields.
Considering the second issue, you may predefine the data fields in case setting the corresponding validation properties in the data binding is required. If you want to handle the validation, you may subscribe to ValidatingItem event. Still, if the logic is implemented in the setter, you are not obliged to handle it.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

I agree that we "are not supposed to enter string values into numeric fields", but this is a valid test and I need to know how these controls behave in an event like this. After more testing yesterday, it looks like the execution of the code breaks (and I get an exception) because I am running the app via the VS 2010 IDE. If I click "Continue" a few times, then I see the WPF form displaying a message at the bottom. So this would be OK I guess when the app has been compiled and running on its own.
Now the business rules. There is a difference between "handling" these rules in the setter properties compared to the
_ValidatingItem
event. The code in the setter properties fires right away and if the preferred method is throwing an exception (like I see in every example) I still don't know where these exceptions can be caught. Now, if we use the _ValidatingItem event, this event does not trigger until the OK button is clicked.
All the examples I have seen so far don't work the way I would expect. If you have code samples that show Telerik's preferred way of doing validation (both in the setter properties and within the _ValidatingItem event), I would ask you to please post them.
Thank you
The most appropriate approach depends entirely on your specific requirements. May you clarify what is the behavior that you expect ? What are the validation that you want to implement ?
Maya
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Now that the data type errors seem to be handled correctly, we can move on to the other two scenarios. The nice thing about putting some validation in the setter properties is that they are triggered right away (instant feedback). The _ValidatingItem event gets triggered when the Click button is clicked (like a Page.IsValid in ASP.NET)
Now, what I just discovered is that if I am running the app thru VS, the code stops, reporting an exception (and it does not run pass that point). If I deploy, it works as I would expect. This was the missing link for me. Now the question is why the different behavior.
The inner exception thrown in this case will be caught only in debug mode, when the Common Language Runtime Exception are enabled. However, this exception will be swallowed in release mode and you will get the validation error in the RadDataForm. You will get the same behavior with DataForm as well.
Maya
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
