Customizing the DataForm using Data Annotations

In the previous recipes, we looked at how to easily display an object or a collection of objects using a DataForm, which includes a lot of functionalities out of the box. However, as you might have noticed, the generated fields aren't always the way you'd want them to be. The labels could be more descriptive or user-friendly, a field could be invisible or read-only, and so on. To achieve this, you can use helpers—Data Annotations. They will define how the DataForm should be generated.

In this recipe, we'll use helpers in the form of Data Annotations to change the auto-generation of our DataForm.

Getting ready

We're starting from the solution that we completed in the previous recipe. If you didn't ...

Get Silverlight 4 Data and Services Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.