Sunday, April 3, 2011

Silverlight 2 datagrid headers

Is there a way to change the column headers of a SL2 datagrid during databinding? I'm looking for something similar to ASP.net's rowDataBound, I'm looking at _LoadingRow is this the correct event?

From stackoverflow
  • You can bind DataColumns in your XAML

     <data:DataGridTextColumn Header="Latitude" Binding="{Binding lat}"  IsReadOnly="True"  />
    
  • Why would you change column headers based on row data. Binding/changing column headers should not be row driven.

    Jeff Yates : This should be a comment rather than an answer.
  • As suggested by rAyt in their answer, you can add bindings to the columns. With an appropriate binding and possibly a value converter, you could use this mechanism to update the headers.

    You can also set the DataGrid to auto-generate columns based on the collection data. You may find this a better route. You can also modify the auto-generated columns as described by this MSDN article.

0 comments:

Post a Comment