views:

578

answers:

1

My WPF datagrid's columns are fixed width, which means long text in the rows are cut off. How can I have the text wrap?

+2  A: 

You can replace the cell with a Textblock with Textwrapping enabled. i.e.

<dg:DataGridTemplateColumn Header="Description" Width="*">
   <dg:DataGridTemplateColumn.CellTemplate>
       <DataTemplate>
           <TextBlock Text="{Binding Description}" TextWrapping="WrapWithOverflow"/>                                    
       </DataTemplate>
   </dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
Asif
How can I then edit the cell text?
Marcel
Textblock is read only. you should use TextBox.
Nasit