# grid-intervalgrouping

> GridControl with interval-based grouping hierarchy, nested row formatting, and custom cell styling.

**Framework:** wpf  **Component:** Grid  **Variant:** intervalgrouping

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/wpf/grid-intervalgrouping.json
```

**Install Package(s)**

```bash
dotnet add package Syncfusion.SfGrid.WPF
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/grid-intervalgrouping/grid.xaml

```xaml
<UserControl x:Class="syncfusion.datagriddemos.wpf.IntervalGrouping.Grid"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
        xmlns:interactivity="http://schemas.microsoft.com/xaml/behaviors"
        xmlns:local="clr-namespace:syncfusion.datagriddemos.wpf.IntervalGrouping"
        Unloaded="OnSampleUnloaded">
    <UserControl.Resources>
        <local:IntervalGroupingViewModel x:Key="viewmodel" />
    </UserControl.Resources>

    <Grid Background="White" DataContext="{StaticResource viewmodel}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!-- Information Header -->
        <Border Grid.Row="0" Background="#F5F5F5" Padding="10" BorderBrush="#E0E0E0" BorderThickness="0,0,0,1">
            <StackPanel>
                <TextBlock FontWeight="Bold" FontSize="14" Foreground="#333">
                    Sample: Interval Grouping
                </TextBlock>
                <TextBlock FontSize="12" Margin="0,5,0,0" Foreground="#666">
                    This sample demonstrates grouping capabilities in the DataGrid control, including grouping by intervals and custom grouping.
                </TextBlock>
            </StackPanel>
        </Border>

        <!-- Options -->
        <Border Grid.Row="1" Background="#FAFAFA" Padding="10" BorderBrush="#E0E0E0" BorderThickness="0,0,0,1">
            <StackPanel>
                <TextBlock x:Name="textBlock1" Margin="5" FontSize="14" FontWeight="Bold" Text="Interval Grouping" />
                <TextBlock x:Name="textBlock2" Margin="5" HorizontalAlignment="Left" FontSize="13" FontWeight="Bold" Text="Order ID Column" TextWrapping="Wrap" />
                <TextBlock x:Name="textBlock3" Margin="5" HorizontalAlignment="Left" FontSize="12" FontWeight="Normal" Text="Groups based on intervals" TextWrapping="Wrap" />
                <TextBlock x:Name="textBlock4" Margin="5" HorizontalAlignment="Left" FontSize="13" FontWeight="Bold" Text="Customer ID Column" TextWrapping="Wrap" />
                <TextBlock x:Name="textBlock5" Margin="5" HorizontalAlignment="Left" FontSize="12" FontWeight="Normal" Text="Groups based on starting letter" TextWrapping="Wrap" />
                <TextBlock x:Name="textBlock6" Margin="5" HorizontalAlignment="Left" FontSize="13" FontWeight="Bold" Text="Order Date, Shipped Date column" TextWrapping="Wrap" />
                <TextBlock x:Name="textBlock7" Margin="5" HorizontalAlignment="Left" FontSize="12" FontWeight="Normal" Text="Order Date - Groups based on day" TextWrapping="Wrap" />
                <TextBlock x:Name="textBlock8" Margin="5" HorizontalAlignment="Left" FontSize="12" FontWeight="Normal" Text="Shipped Date - Groups based on date range" TextWrapping="Wrap" />
            </StackPanel>
        </Border>

        <!-- Grid Section -->
        <syncfusion:SfDataGrid
            Grid.Row="2"
            x:Name="sfGrid"
            Margin="5"
            AllowEditing="True"
            AllowGrouping="True"
            AllowResizingColumns="True"
            AutoGenerateColumns="False"
            ColumnSizer="Star"
            IsGroupDropAreaExpanded="True"
            ItemsSource="{Binding Orders}"
            NavigationMode="Cell"
            ShowGroupDropArea="True">
            <interactivity:Interaction.Behaviors>
                <local:DataGridGroupColumnChangingBehavior />
            </interactivity:Interaction.Behaviors>

            <syncfusion:SfDataGrid.GroupColumnDescriptions>
                <syncfusion:GroupColumnDescription ColumnName="OrderDate" />
            </syncfusion:SfDataGrid.GroupColumnDescriptions>

            <syncfusion:SfDataGrid.Columns>
                <syncfusion:GridNumericColumn
                    HeaderText="Order ID"
                    MappingName="OrderID"
                    NumberDecimalDigits="0"
                    TextAlignment="Right" />
                <syncfusion:GridTextColumn
                    AllowSorting="True"
                    HeaderText="Customer ID"
                    MappingName="CustomerID" />

                <syncfusion:GridDateTimeColumn
                    AllowSorting="True"
                    HeaderText="Order Date"
                    MappingName="OrderDate"
                    TextAlignment="Right" />

                <syncfusion:GridMaskColumn
                    HeaderText="Contact Number"
                    MappingName="ContactNumber"
                    Mask="(99)-9999"
                    TextAlignment="Right" />
                <syncfusion:GridComboBoxColumn
                    HeaderText="Product Name"
                    ItemsSource="{Binding Path=ComboBoxItemsSource, Source={StaticResource viewmodel}}"
                    MappingName="ProductName"
                    TextTrimming="CharacterEllipsis" />
                <syncfusion:GridCurrencyColumn
                    CurrencyDecimalDigits="0"
                    HeaderText="Unit Price"
                    MappingName="UnitPrice" />
                <syncfusion:GridNumericColumn
                    HeaderText="Quantity"
                    MappingName="Quantity"
                    NumberDecimalDigits="0" />
                <syncfusion:GridPercentColumn HeaderText="Discount" MappingName="Freight" />
                <syncfusion:GridDateTimeColumn
                    HeaderText="Shipped Date"
                    MappingName="ShippedDate"
                    TextAlignment="Right" />

                <syncfusion:GridCheckBoxColumn HeaderText="Closed" MappingName="IsShipped" />
            </syncfusion:SfDataGrid.Columns>

        </syncfusion:SfDataGrid>
    </Grid>
</UserControl>
```
