Home Forums WPF controls Xceed DataGrid for WPF Wrap text in DataGrid Headers

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26217 |

    I can not figure out how to wrap the text in my headers. I have a couple of headers that are 4 or 5 words long and I would like those to wrap to a second line.

    I have tried making my headers taller by changing the height. That did not work. I also tried setting the ColumnManagerCell TextWrapping property to “wrap” and that did not work.

    Any ideas?

    TIA!

    Imported from legacy forums. Posted by Dugrhill (had 2826 views)

    Xceed Support
    Member
    Post count: 5658

    I experienced a little bit and came to that solution:

    <xcdg:Column FieldName=”MyColumn”
    Title=”asdf asdfalskjhfa asdfkjlhasdflkjasdfh asdklfjhalksjhfasdf”
    Width=”225″
    TitleTemplate=”{StaticResource columnTitleTemplate}”/>

    With this template in the resources:

    <DataTemplate x:Key=”columnTitleTemplate”>
    <TextBlock Text=”{Binding}”
    TextWrapping=”Wrap”
    MaxWidth=”{Binding RelativeSource={RelativeSource AncestorType={x:Type xcdg:Cell}}, Path=ParentColumn.Width}” />
    </DataTemplate>

    Imported from legacy forums. Posted by Marcus [Xceed] (had 500 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for the effort Marc.

    I tried to implement your solution but did not get the desired result. The long text in my header did not wrap to a second line. I’m sure your solution would work if I knew what I was doing. But I don’t.

    Thanks for trying.

    Dugr

    Imported from legacy forums. Posted by Dugrhill (had 3914 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Dugr,

     Was trying to achieve the same thing as yourself, playing with what Marc sent through I came up with:

    <

    xcdg:Column FieldName=”Field1″ ReadOnly=”True” Title=”Field with lots of text to be wrapped” MaxWidth=”100″ TextWrapping=”WrapWithOverflow” >

    <xcdg:Column.TitleTemplate>

    <DataTemplate>

    <TextBlock TextWrapping=”Wrap” Text=”{Binding}” MaxWidth=”100″/>

    </DataTemplate>

    </xcdg:Column.TitleTemplate>

    </xcdg:Column>

     

    which appears to do the trick, I feel that the solution Marc offered is the way to go as it allows dynamic configuration through the resources, rather than doing the template on the column as I have, however this at least gave me an idea of what was going on. Hopefully this can be of use to you.

     

    thanks

    Dave

    Imported from legacy forums. Posted by David (had 1461 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.