IList and IEnumerable Data Sources

  • 2 minutes to read

The Items Source Configuration Wizard allows you to bind the PivotGridControl to any object that implements the IList or IEnumerable interfaces (to learn more about such objects, see Traditional Data Binding Methods). This topic guides you through the steps needed to do this.

NOTE

In this topic, the data class from the following example will be used: How to: Bind a Control to Data Created at Runtime.

  1. Click the PivotGridControl's smart tag and select the Items Source Wizard command.

    WpfPivot_ProvidingData_SmartTag

  2. In the invoked Items Source Configuration Wizard, select IList/IEnumerable...

    DataSourceConfigurationWizard_IList

    ... and click Next.

  3. On the next page, select the required binding method.

    DataSourceConfigurationWizard_ADO_BindingMethod

    • Simple Binding - allows you to bind the PivotGridControl to a data source directly.
    • Manipulating Data via ICollectionView - allows you to bind the PivotGridControl to a data source using the ICollectionView component, which enables collections to have the functionalities of current record management, custom sorting, filtering, and grouping. To learn more, see ICollectionView Specifics.

    Select Simple Binding and click Next.

  4. On the final page, you need to specify the name of the required data class.

    ItemsSourceConfigurationWizard_IList_Finish

    Start typing the name of the data class.

    ItemsSourceConfigurationWizard_IList_SelectClass

    Then, select the required class from the list of classes offered by the Items Source Configuration Wizard and click Finish.

  5. The PivotGridControl will be bound to the created data source.

    WpfPivot_BoundToDataSet

    You can now use the Retrieve Fields command to retrieve the available data source fields.

    NOTE

    Note that the Items Source Configuration Wizard adds the created data source to window resources.

    <dx:DXWindow.Resources>
            <dx:IEnumerableDataSource x:Key="IEnumerableDataSource">
                <dx:DesignDataManager.DesignData>
                    <dx:DesignDataSettings DataObjectType="{x:Type local:Record}" RowCount="5"/>
                </dx:DesignDataManager.DesignData>
            </dx:IEnumerableDataSource>
        </dx:DXWindow.Resources>
    

    Then, the PivotGridControl is bound to the created data source.

    <dxpg:PivotGridControl DataSource="{Binding Data, Source={StaticResource IEnumerableDataSource}}"/>