I have defined a custom caption for grouped items in my WinUI3 SfDataGrid as follows:
<Style x:Key="PlayerRegistrationCaptionSummaryCellStyle" TargetType="grid:GridCaptionSummaryCell">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="grid:GridCaptionSummaryCell">
<Border Background="{TemplateBinding Background}" Padding="2">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="8"
Width="400" HorizontalAlignment="Left">
<StackPanel.Background>
<SolidColorBrush Color="{Binding Key,Converter={StaticResource RegistrationStatusBackgroundConverter}}"
Opacity=".4"/>
</StackPanel.Background>
<SymbolIcon Width="20" Height="20" Symbol="{Binding Key, Converter={StaticResource RegistrationStatusSymbolConverter}}"/>
<TextBlock Text="{Binding Key,Converter={StaticResource RegistrationStatusDescriptionConverter}}"
VerticalAlignment="Center"/>
<TextBlock Text=" (" Foreground="Gray"/>
<TextBlock Text="{Binding ItemsCount}" Foreground="Gray"/>
<TextBlock Text=" items)" Foreground="Gray"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<grid:SfDataGrid x:Name="grdPlayerRegistrations"
ItemsSource="{x:Bind Viewmodel.PlayerRegistrationRecords}"
AutoGenerateColumns="False" ColumnWidthMode="SizeToHeader"
AllowGrouping="True"
ShowColumnWhenGrouped="True"
LiveDataUpdateMode="AllowSummaryUpdate,AllowDataShaping"
CaptionSummaryCellStyle="{StaticResource PlayerRegistrationCaptionSummaryCellStyle}"
ShowGroupDropArea="True">
<grid:SfDataGrid.GroupColumnDescriptions>
<grid:GroupColumnDescription ColumnName="Status" />
</grid:SfDataGrid.GroupColumnDescriptions>
This works, only the ItemsCount property is not updated when items are added to the ItemsSource. If I do not set a CaptionSummaryCellStyle the number of items in a group is updated. How can I solve this?