Dynamically Build Grid

3 posts, 0 answers
  1. Mark
    Mark avatar
    61 posts
    Member since:
    Dec 2010

    Posted 22 Apr 2012 Link to this post

    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. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 23 Apr 2012 Link to this post

    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 >>

  3. Mark
    Mark avatar
    61 posts
    Member since:
    Dec 2010

    Posted 23 Apr 2012 Link to this post

    thank Didie, that seems to point to a solution, I will give feedback if this solves the problem.
Back to Top