Freezing Columns in the Silverlight DataGrid

Freezing columns is just one of the many things you can do with the Silverlight DataGrid. Read more about the features that the Silverlight 2 DataGrid has to offer...

Freezing Columns

Have you ever been working with a large enough number of columns that you get horizontal scrolling, but you want some of the columns to not scroll?  Think of a column such as Employee Name that you want to remain visible while you scroll through ten weeks of sales data.  You might want to see which employee had the best sales for week 4.  Since the Employee column is on the far left, any amount of scrolling causes it to scroll out of view, that is unless you freeze it.  This causes it to not scroll and always be visible putting your other data in context.


To freeze columns, you simply set the FrozenColumnCount property on the DataGrid to the number of columns you want to freeze.  For instance, to freeze the Employee column pictured above, you would write:


employeeSalesGrid.FrozenColumnCount = 1;


EmployeeSalesGrid.FrozenColumnCount = 1


If you are programmatically working with a column and want to know if it is frozen or not, you can check the IsFrozen property on the Column.  This is a readonly property that will let you know if the column you are working with is frozen.

Comments (13)

  1. In this issue: Tim Heuer, Scott Morrison, Corey Schuman, and Jesse Liberty A whole bunch of folks are

  2. unruledboy says:

    could a single column width (like "Week 5") to be fixed so user could not resize it?

  3. Yes, a single column width can be fixed, preventing a user from resizing it, by setting the CanUserResize property on the column to false.

    <DataGridTextColumn Binding="{Binding Week5}" Header="Week 5" CanUserResize="false" />

    Hope this helps,


  4. Ram Hegde says:

    Thanks for the nice posts on data grid. I had one more requirement while showing the grid. I want to show the record number (index) as the first column and freeze it so that at any scroll position, you know which index you are on. This will remain same even if some other columns are resorted. Do you have suggestion how we can implement this?

  5. Bruce Denham says:

    What if I want to Freeze the first column in the grid and the last column?

  6. De Tran says:

    It seems the DataGrid API is bit short for not providing a way to free columns on the right.  Currently I have to do a whole bunch of calculation to make the columns on the right looked frozen.  

    Probably this is a feature that should be added.

  7. ledz says:

    I would also like to do that, freeze columns to the left and to the right; no ideas?

  8. Thanks for the feedback all.  

    To clarify your scenarios around freezing the columns to the right.  

    1) Is it only important that the column is always visible and always on the rightmost edge of the DataGrid, or is allowing other columns to scroll, and having them scroll under that frozen column, critical as well?

    2) Does anyone have a scenario where they need to freeze columns on both the left and the right at the same time?  What are you trying to achieve in these scenarios?



  9. Faiyaz says:

    There could be many scenarios where it could be required, but question is-is thera a way to freeze right side column or not ? It will be great if you can shed some light on it.


  10. To clarify: there is no way to Freeze a column to the right if you want the others to scroll.  

    If you just want a column to always be flush right, and horizontal scrolling is not a concern, you can set any of the column widths to its left to star width.

    Hope this helps.


  11. daverupp says:

    hi scott

    We try to follow the drilldown concept of the iphone with a arrow on the right side.

    So as straight forward we choosed the rowheader to visualize the arrow on the right side. When we have a lot of columns the rowheader will be not visible anymore.

    So I have to ask again, is there no way to set a right horizontal offest like the datagrid calculates it for the left side depending on the frozencolumncount?

    Will this feature be available in future releases of the datagrid?

    thx for help and answering…

    kind regards


Skip to main content