Dotnetdreamer's Weblog

SharePoint, Silverlight and Azure

Silverlight 2 DataGrid – Frozen Columns

Posted by Ramprasad Navaneethakrishnan on January 31, 2009

Not long ago, we had a requirement in our project where a datagrid should hold 14 columns, out of which the first column should be static and the remaining should be scrollable.

ASP.NET datagrid does not support such requirements or for that matter no control in ASPNET toolbox. So ultimately we had to deal with multiple tables and messy javascripts to satisfy that requirement. Now that piece of code is difficult to manage and not friendly for change.

Now, Silverlight 2 DataGrid is released which comes with new in-built features like Auto-Sizing, Multiple-Column Sorting, Frozen Columns etc..

Frozen Column:

Forzen Column makes the column to freeze(remain static while other columns are scrolling). When you have 14, 15 columns in a datagrid, you might want the first column or the first two column to remain static while scrolling thorough the other columns.

FrozenColumnCount:

The FrozenColumnCount property of the Silverlight 2 DataGrid takes the number of columns the user want to freeze starting from the left most column.

Example:

This is my Silverlight 2 DataGrid..

<my: DataGrid
x:Name=”myDataGrid”>
</my: DataGrid>

It has 10 columns and by default all the columns are scrollable..

Silverlight 2 DataGrid

Silverlight 2 DataGrid

When FrozenColumnCount is set to 1, the first column will remain static and the scroll bar appears only for the remaining 9 columns.

<my: DataGrid
x:Name=”myDataGrid”
FrozenColumnCount=”1″>
</my: DataGrid>

this is how the DataGrid looks

Silverlight 2 DataGrid with Frozen Column

Silverlight 2 DataGrid with Frozen Column

In case, if we want to make the first two columns to remain static, then the FrozenColumnCount should be set to 2.

<my: DataGrid
x:Name=”myDataGrid”
FrozenColumnCount=”2″>
</my: DataGrid>

Silverlight 2 DataGrid with Frozen Columns

Silverlight 2 DataGrid with Frozen Columns

Advertisements

One Response to “Silverlight 2 DataGrid – Frozen Columns”

  1. shankar said

    Hi ,
    Nice to learn that silverlight provides so much flexiblity for UI design. We are eager to learn other options provided by the same.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: