GridControl: Binding row to a data source
In addition to GridControl.ItemsSource property that has become a common method of data binding in the grid, the grid provides a new API to bind individual rows to data sources Row.ItemsSource.
Row.ItemsSource = 'your data source';
The bound data source may implement IList or IBindingList interfaces. If the bound data source implements IBindingList interface, the grid subscribes to notifications of this data collection and enables automated thread-safe management of content changes.
public class Basket
{
private readonly BindingList<Order> _orders = new BindingList<Order>();
public IList<Order> Orders
{
get { return _orders; }
}
}
public void InitializeGrid(GridControl grid, IList<Basket> baskets)
{
grid.ItemsSource = baskets;
foreach(Basket basket in baskets)
{
Row row = grid.DataObjects.FindFirstRow(basket);
if(row != null)
{
row.ItemsSource = basket.Orders;
}
}
}
Back to Wpf GridControl features