ComponentOne DataGrid for WPF and Silverlight
DataGrid for WPF and Silverlight Overview / Getting Started / Quick Start / Step 3 of 4: Setting the ItemsSource
In This Topic
    Step 3 of 4: Setting the ItemsSource
    In This Topic

    In the last step you added a data model named Product. In this step you will generate a collection of data objects using this model, and set this list to display in the C1DataGrid control.

    To display a collection of data objects in the C1DataGrid control, complete the following steps:

    1. Open MainWindow.cs or MainWindow.vb.
    2. After the boiler-plate initialization code, add the following code which generates a list of 100 random products:
      C#
      Copy Code
      List<Product> _products = new List<Product>();
      for(int i = 0; i < 100; i++)
      {
          _products.Add(new Product());
      }
      
    3. Set the ItemsSource property of the C1DataGrid to the collection of products. We named our C1DataGrid control as “ProductsDataGrid” back in step 1.

      ProductsDataGrid.ItemsSource = _products.