How get a WPF Datagrid with cells that wrap text instead of truncating it?

Solution 1:

Thanks for your help @H.B., this did the trick for me (alignment is optional):

<DataGrid.Columns>               
    <DataGridTextColumn Header="Wrapped & centered" Binding="{Binding field}">
        <DataGridTextColumn.ElementStyle>
             <Style>                            
                 <Setter Property="TextBlock.TextWrapping" Value="Wrap" />
                 <Setter Property="TextBlock.TextAlignment" Value="Center"/>
             </Style>
         </DataGridTextColumn.ElementStyle>
    </DataGridTextColumn>
</DataGrid.Columns>

Solution 2:

I made something similar to D.Rosados solution. Mine is however reusable if you have more columns that needs wrapping.

<UserControl.Resources>
    <Style TargetType="{x:Type TextBlock}" x:Key="WrapText">
        <Setter Property="TextWrapping" Value="Wrap"/>
    </Style>
</UserControl.Resources>

<DataGrid.Columns>
    <DataGridTextColumn IsReadOnly="False" Header="Address" 
     Binding="{Binding Address}" ElementStyle="{StaticResource WrapText}" Width="150"/>
</DataGrid.Columns>