XPO Data Source

  • 2 minutes to read

The Items Source Configuration Wizard allows you to bind the PivotGridControl to an XPO data source. This topic goes over the steps needed to do this.

  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 DevExpress ORM Tool (XPO)...

    DataSourceConfigurationWizard_XPO

    ... and click the New Data Source button placed within the Data Sources area.

    DataSourceConfigurationWizard_SelectAdoNet_NewDataSource

  3. The following message will appear.

    ItemsSourceConfigurationWizard_RebuildWarning

    Click OK.

  4. On the next page, you can generate persistent objects using the ORM Data Model Wizard or you can create persistent objects manually. Select the required option, specify the object name and click Add.

    Pivot_AddXPODataModelDialog

    To learn how to work with XPO, see DevExpress ORM Tool.

    IMPORTANT

    After you create a data model, rebuild the solution.

  5. After creating a data source, click Items Source Wizard again.

    WpfPivot_ProvidingData_SmartTag

  6. In the invoked Items Source Configuration Wizard, select the created data model.

    DataSourceConfigurationWizard_XPO_SelectModel

    Click Next.

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

    DataSourceConfigurationWizard_XPO_BindingMethods

    • Binding via the XPCollection Component - Bind to data using the XPCollection component that is a collection of persistent objects.
    • Binding via the XPView Component - Bind to data using the XPView component that is only intended for displaying data.
    • Server Side Data Processing - Bind to data using server mode. In this case, all data processing is delegated to the database server.

    Select Binding via the XPCollection Component and click Next.

  8. On the final page, you can specify the table.

    DataSourceConfigurationWizard_XPO_Finish

    Select the required table and click Finish.

  9. 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:XPCollectionDataSource x:Key="XPCollectionDataSource" 
                                       DisplayableProperties="CustomerID;EmployeeID;Freight;OrderDate;OrderID;RequiredDate;ShipAddress;ShipCity;ShipCountry;ShipName;ShippedDate;ShipPostalCode;ShipRegion;ShipVia" 
                                       ObjectType="{x:Type nwind:Orders}">            
                <!-- DesignDataManager -->
                <dx:XPCollectionDataSource.Session>
                    <Xpo:UnitOfWork IsObjectModifiedOnNonPersistentPropertyChange="{x:Null}" TrackPropertiesModifications="False"/>
                </dx:XPCollectionDataSource.Session>
            </dx:XPCollectionDataSource>
        </dx:DXWindow.Resources>
    

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

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

    To initialize the database connection for the created data model, do one of the following.

    • If you used the ORM Data Model Wizard to create a data model, call the ConnectionHelper.Connect method in the application's Main method.
    • If you did not use the wizard, then manually assign a Data Layer to the static XpoDefault.DataLayer property instead of calling ConnectionHelper.Connect.