We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Textwrapping

Hi,

I'm trying to get the Text to get wrapped in a Datagrid.
I've set up a Style:

<Style x:Key="wrappingText" TargetType="syncfusion:GridCell">
            <Setter Property="TextBlock.TextWrapping" Value="Wrap"/>
            <Setter Property="Background" Value="Aqua"/>
</Style>

and applied to in c#

if(e.Column is GridTextColumn)
            {
                e.Column.CellStyle = App.Current.Resources["wrappingText"] as Style;
            }

The Background changed, but the wrapping fails.

Thanks in advance

Timo

1 Reply

FP Farjana Parveen Ayubb Syncfusion Team December 31, 2019 09:15 AM UTC

Hi Timo, 
 
Thank you for using Syncfusion controls. 
 
By default, GridTextColumn having TextWrapping property, so you can set the wrapping for the text using this property. Please refer the below code example 
 
private void SfDataGrid_Loaded(object sender, RoutedEventArgs e) 
{ 
   foreach(var column in sfDataGrid.Columns) 
    { 
        if (column is GridTextColumn) 
            (column as GridTextColumn).TextWrapping = TextWrapping.Wrap; 
    } 
} 
 
 
 
Please let us know if you need any further details on this. 
 
Regards, 
Farjana Parveen A 


Loader.
Live Chat Icon For mobile
Up arrow icon