This is a migrated thread and some comments may be shown as answers.

Dynamically Build Grid

2 Answers 21 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 23 Apr 2012, 03:19 AM
As I have had no joy from the 2 threads I have created to address the wrapping of header text in autogenerated columns

http://www.telerik.com/community/forums/silverlight/gridview/wrap-header-text-in-dynamic-structured-gridview.aspx 
http://www.telerik.com/community/forums/silverlight/gridview/wrapping-text-in-gridviewcolumn-header.aspx 

I would like your opinion on building the grid in code and assigning it from the code behind. If I create each column in code, adding them to a collection of columns and then assign the collection to the datagrid will I be able to convince the header text to wrap.

Note the header text comes from the database and IS NOT HARD CODED so the xaml definition does not work.

2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 23 Apr 2012, 01:26 PM
Hello,

 You could set the Header like so:

GridViewDataColumn column = new GridViewDataColumn();
column.DataMemberBinding = new System.Windows.Data.Binding("Name");
column.Width = 50;
var header = new TextBlock { Text = "Line1 very long line", TextWrapping=TextWrapping.Wrap}; 
column.Header = header;
this.clubsGrid.Columns.Add(column);

I hope that this is what you need.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mark
Top achievements
Rank 1
answered on 24 Apr 2012, 01:09 AM
thank Didie, that seems to point to a solution, I will give feedback if this solves the problem.
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Mark
Top achievements
Rank 1
Share this question
or