How to change the column stacking at runtime in StackedHeader of WPF DataGrid?
You can define more than one header for WPF DataGrid (SfDataGrid) using StackedHeaderRows and you can define the columns by setting StackedHeaderRows.StackedColumns. The columns in StackedHeaderRow are stacked or grouped based on the StackedColumn.ChildColumns property.
The following code example has DataGrid defined with StackedHeaderRows.
<Syncfusion:SfDataGrid Name="SfdataGrid"
AutoGenerateColumns="True"
ItemsSource="{Binding Employee}">
<Syncfusion:SfDataGrid.StackedHeaderRows>
<Syncfusion:StackedHeaderRow>
<Syncfusion:StackedHeaderRow.StackedColumns>
<Syncfusion:StackedColumn ChildColumns="EmployeeID,Name"
HeaderText="Employee Details"/>
<Syncfusion:StackedColumn ChildColumns="ContactID,Title"
HeaderText="Contact details"/>
<Syncfusion:StackedColumn ChildColumns="SickLeaveHours,Salary"
HeaderText="Salary Details"/>
</Syncfusion:StackedHeaderRow.StackedColumns>
</Syncfusion:StackedHeaderRow>
</Syncfusion:SfDataGrid.StackedHeaderRows>
</Syncfusion:SfDataGrid>The following screenshot shows DataGrid with StackedHeaderRows.

Figure 1: DataGrid with StackedHeaderRows
private void AddinStackedHeaderRow_Click(object sender, RoutedEventArgs e)
{
var childcolumn = this.SfdataGrid.StackedHeaderRows[0].StackedColumns[0].ChildColumns;
this.SfdataGrid.StackedHeaderRows[0].StackedColumns[0].ChildColumns = childcolumn + "," + "BirthDate" + "," + "NationalIDNumber";
}The following screenshot shows the output of the SfDataGrid with the newly updated ChildColumns to the already existing StackedColumn in StackedHeaderRows.

Figure 2: ChildColumns added to the existing StackedColumn