Xceed DataGrid for WPF v7.2 Documentation
Configuring Spanned Cells

The following example demonstrates how to center vertical and horizontal content alignment through a SpannedCellConfigurationSelector.

XAML
Copy Code
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
  <Grid.Resources>
    <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
                                       Source="{Binding Source={x:Static Application.Current}, Path=Orders}" />
    <xcdg:CustomSpannedCellConfigurationSelector x:Key="configurationSelector" />
  </Grid.Resources>
  <xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource cvs_orders}}"
                        SpannedCellSelector="{StaticResource configurationSelector}">
    <xcdg:DataGridControl.View>
      <xcdg:TableView AllowCellSpanning="True" />
    </xcdg:DataGridControl.View>
    <xcdg:DataGridControl.Columns>
      <xcdg:Column FieldName="ShipCountry"
                   CellSpanningDirection="Row" />
    </xcdg:DataGridControl.Columns>
  </xcdg:DataGridControl>
</Grid>

 

C#
Copy Code
public sealed class CustomSpannedCellConfigurationSelector : SpannedCellConfigurationSelector
{
  public override ISpannedCellConfiguration SelectConfiguration(object content, IEnumerable<SpannedCellFragment> fragments)
  {
    return new SpannedCellConfiguration() { HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center };
  }
}