Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

4. The Data Grid > Using custom columns in the DataGrid

Using custom columns in the DataGrid

Applies to Silverlight 3, 4 and 5

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 Displaying the data in a customized DataGrid. 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. In addition to 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 in the previous recipes of this chapter. You can also use the start solution located in the Chapter04/Datagrid_Custom_Columns_Starter folder in the code bundle that is available on the Packt website. The completed solution for this recipe can be found in the Chapter04/Datagrid_Custom_Columns_Completed folder.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint