Sunday, May 3, 2009

Silverlight : DataGrid Control

DataGrid

DataGrids are fundamental UI controls. They radically simplify the task of displaying structured data to users by automatically handling the rendering of rows, columns, headers, and data navigation. Silverlight's data grid is no exception. While it is far from being a complete or "advanced" grid control by today's WinForms and ASP.NET standards, it does provide basic grid functionality.

To use the DataGrid control, you must simply bind the Grid to a list of items (that implement IEnumerable) via the ItemSource property. In the simplest approach, the Grid will automatically generate columns based on the data you supply and even render "special" column types- like checkbox columns- based on your data types. You can, of course, take more control and manually define the columns that will be rendered in your grid by setting the AutoGenerateColumns property to false.

We have to add following namespace to use DataGrid:
xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"


<my:DataGrid x:Name="myDataGrid" AutoGenerateColumns="true" />

No comments:

Post a Comment