Using custom columns in the DataGrid

By default, the DataGrid will generate columns for us based on the type of objects that we pass to the control. We looked at this in the Displaying the data in a customized DataGrid recipe. However, we'll want more control over what is being displayed most of the time. We'll want to make decisions such as which columns should be shown, in what order and so on. On top of that, we may want to allow the user to select a value from a ComboBox for a particular column or entirely reformat a value.

In this recipe, we'll take full control over what will be displayed by the DataGrid by creating a number of columns ourselves.

Getting ready

To follow along with this recipe, you can continue using the code that was created ...

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.