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:
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.
You can achieve this by overriding the
GridTableSummaryCell
Style and set the value of theHorizontalContentAlignment
property. Refer to the below code snippet: