One of the main features of Wpf GridControl is the support of binding to one or multiple data sources with GridControl..::..ItemsSource property while simultaneously adding objects with GridControl.Rows.Add(Object) / Row..::..Add(Object) methods.

This feature enables creation of almost any data hierarchy. If a IBindingList data source is bound to the grid, the grid subscribes to events of this list automatically adding, removing or deleting rows. If child rows are added to the row with GridControl.Rows.Add(Object) / Row..::..Add(Object)), these rows are correctly deleted upon relevant notification from IBindingList..::..ListChanged.

C# Copy imageCopy
//Basket class
public class Basket 
{
    //Private fields
    private readonly BindingList<Order> _orders = new BindingList<Order>();

    //Public properties    
    public IList<Order> Orders
    {
        get { return _orders; }
    }
}

//Initialize the grid
public void InitializeGrid(GridControl grid, IList<Basket> baskets)
{
    //Bind the grid to a basket collection
    grid.ItemsSource = baskets;

    //Add orders to each basket row
    foreach(Basket basket in baskets)
    {
        Row row = grid.DataObjects.FindFirstRow(basket);
        if(row != null)
        {
            foreach(Order order in basket.Orders)
            {
                row.Add(order);
            }
        }
    }

    //Add some other data object on the topmost hierarchical level
    grid.Rows.Add(new SomeOtherData());
}