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

Unable to set foreground and fontfamily for data inside grids

I am using below code to apply styling for the data inside grids. But it's not working. please refer the screen shot for the output. I tried using CellStyle aswell but no luck.  Please let me know the correct process as I am very new to this.

<syncfusion:SfDataGrid x:Name="dataProgramGrid" AutoGenerateColumns="False"  SelectionMode="Multiple" SelectionUnit="Row"
                               ItemsSource="{Binding objReportActiveProgramsSurveyData}"   HeaderStyle="{StaticResource headerStyle}" >
                            <syncfusion:GridTextColumn HeaderText="Program" MappingName="szProgramName" TextWrapping="Wrap" Width="230">
                                    <Style TargetType="syncfusion:GridCell">
                                        <Setter Property="Foreground" Value="#505050" />
                                        <Setter Property="FontFamily" Value="Segoe UI" />
                                        <Setter Property="FontSize" Value="10" />
                                        <Setter Property="FontWeight" Value="SemiBold" />


Thanks in advance.

Attachment: SfDataGrid_85e2c265.zip

1 Reply

EM Elavarasan M Syncfusion Team July 1, 2016 11:38 AM UTC

Hi Anilkumar,  
Thank you for contacting Syncfusion support.  
We have analyzed your query and please find the below details 
You have write the style to GridHeaderCellControl and set that style to HeaderStyle. In that style, you have set the HorizontalAlignment and VerticalAlignment as Center, so the borders are not arranged as you expected. We suggest you to set the HorizontalContentAlignment and VerticalContentAlignment as center instead on setting HorizontalAlignement and VerticalAlignment.  
You can refer the below UG documentation to know more about the HeaderStyle,  
We have applied the style to the GridCell based on your code example and we are able to set the foreground, fontfamily to the cells as expected. We have attached the sample for this and please find the sample from below,  
You can refer the below UG documentation to know more about the CellStyle,  
We suspect that you have set the style for Text Block  in your application or themes applied then, Foreground and FontFamily will not be changed based in GridCell foreground because GridCell loads TextBlock as its content. However, you can overcome this problem by setting TextBlock style inside GridCell.Resources.    
Still if you are facing the problem then Could you please modify and revert the sample to us based on your scenario, this will help us to provide the better solution to you.  
Elavarasan M

Live Chat Icon For mobile
Up arrow icon