Chapter 17. Data controls: DataGrid and DataForm
This chapter covers
- Learning about the DataGrid
- Turning the grid on its side with the DataForm
- Controlling binding display through attributes
In chapter 16, you learned about binding. I believe binding to be one of the most important topics for Silverlight developers. One reason behind my belief is that the DataGrid and DataForm, as well as data annotations for display, all require binding in order to be useful.
Silverlight 2 included the DataGrid, and Silverlight 3 added the DataForm to the mix of data-centric controls. The DataGrid provides tabular Microsoft Excel–like data view and editing—a mainstay of business applications. The DataForm is like a DataGrid rotated 90 degrees. Where the DataGrid is all about rows and columns for multiple visible entries, the DataForm is about fields and labels for a single visible entry.
Once I cover the DataGrid and DataForm, you’ll see how to annotate properties with simple attributes to control display within the DataGrid and DataForm. You’ll learn about the related input validation attributes in chapter 18.
When used together, the DataForm, DataGrid, and the related data annotations can form the heart of the UI for any forms-over-data or business application and can save you a ton of implementation time. Of the three, the DataGrid is the most often used, so let’s start there.