Welcome to the Xceed Community Sign in | Join | Help
Community Search  

Wrap text in DataGrid Headers

Sort Posts: Previous Next
  •  03-06-2008, 6:33 PM Post no. 11065

    Wrap text in DataGrid Headers

    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!

  •  03-07-2008, 8:44 AM Post no. 11066 in reply to 11065

    Re: Wrap text in DataGrid Headers

    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>
    Marc Laroche
    Software Developer
    Xceed Software Inc.


    I don’t suffer from insanity, I enjoy every minute of it. - Unknown
  •  03-07-2008, 10:53 PM Post no. 11067 in reply to 11066

    Re: Wrap text in DataGrid Headers

    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
  •  05-11-2008, 2:49 AM Post no. 12152 in reply to 11067

    Re: Wrap text in DataGrid Headers

    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

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.