Can´t center text in Syncfusion GridSummaryColumn

110 Views Asked by At

I'm trying without sucess to center or position in other ways the text in the summary row of my Syncfusion SfDataGrid in WPF. I have the following structure:

 <syncfusion:SfDataGrid
        ...
        <syncfusion:SfDataGrid.Columns>
           ...
        </syncfusion:SfDataGrid.Columns>
        <syncfusion:SfDataGrid.TableSummaryRows>
            <syncfusion:GridTableSummaryRow
                CalculationUnit="SelectedRows"
                Position="Top"
                ShowSummaryInRow="False">
                <syncfusion:GridSummaryRow.SummaryColumns>
                    <syncfusion:GridSummaryColumn
                        Name="SomaQuantidade"
                        Format="'{Sum:#.0}'"
                        MappingName="Quantidade"
                        SummaryType="DoubleAggregate"/>
                    ...
                </syncfusion:GridSummaryRow.SummaryColumns>
            </syncfusion:GridTableSummaryRow>
        </syncfusion:SfDataGrid.TableSummaryRows>
    </syncfusion:SfDataGrid>

And it works fine, except the text is always left aligned in the column:

enter image description here

There´s no alignment property in GridSummaryColumn nor GridTableSummaryRow so I tried creating a DataTemplate for the GridSummaryColumn, with a textblock like this:

<TextBlox HorizontalAlignment="Stretch" TextAlignment="Center" Text="{Binding ...}"/>

It also shows aligned to the left! I couldn't find help for this in Syncfusion docs, so I would really appreciate if anyone could point me out anyway to get these summary texts aligned.

1

There are 1 best solutions below

0
On BEST ANSWER

You can achieve this by overriding the GridTableSummaryCell Style and set the value of the HorizontalContentAlignment property. Refer to the below code snippet:

<Window.Resources>
 <Style TargetType="syncfusion:GridTableSummaryCell">
     <Setter Property="HorizontalContentAlignment" Value="Center"/>
 </Style>
</Window.Resources>