I am using the WPF DataGrid control in .NET 4 that have a DataGridTextColumn.
I want to be able to enter multi-line text. The line breaks are formatted correctly when I bind data to the column, but I've found no way of creating the line breaks when editing the text.
<DataGrid ItemsSource="{Binding MyMessages}">
<DataGrid.Columns>
<DataGridTextColumn Header="Message" Binding="{Binding Path=Message}" Width="Auto"/>
<DataGrid.Columns>
</DataGrid>
Any suggestions?
Try:
<DataGridTextColumn Header="Message" Binding="{Binding Path=Message}" Width="Auto">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
</Style>
</DataGridTextColumn.ElementStyle>
<DataGridTextColumn.EditingElementStyle>
<Style TargetType="TextBox">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="AcceptsReturn" Value="true" />
</Style>
</DataGridTextColumn.EditingElementStyle>
</DataGridTextColumn>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With