Click here to Skip to main content
11,925,896 members (61,098 online)
Rate this:
Please Sign up or sign in to vote.
See more: WPF DataGrid

I wanted to Text wrap my columns of a Datagrid to a particular width. Please provide me any possible way to achieve this.

Thanks & Regards,
Posted 7-Jun-13 4:40am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


Please refer to this[^] MSDN documentation. Basically If you are using a DataGridTextColumn, you need to define the Style for the DataGridTextColumn.ElementStyle.
    <DataGridTextColumn Header="Wrapped & centered" Binding="{Binding field}">
                 <Setter Property="TextBlock.TextWrapping" Value="Wrap" />
                 <Setter Property="TextBlock.TextAlignment" Value="Center"/>
Prasad Khandekar 7-Jun-13 10:13am
Thank you Sir.
Mathi2code 11-Jun-13 2:00am
Hi Prasad,
Thanks for replying. The above is completely working good.
Could you please help me out in formatting the header text and its background. Like I want to make the header text alone to be bold and its background should be some color.

Please let me know the possible way to achieve.
Prasad Khandekar 11-Jun-13 2:14am

You can do this via HeaderStyle. Please see the MSDN link for more details. (

Mathi2code 11-Jun-13 16:23pm
Thanks Prasad

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 7 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100