Skip to main content

Remove Data Providers from the Data Source Wizard

  • 3 minutes to read

This help topic explains on how to customize data providers list in the Data Source Wizard.

Remove Data Providers at Design Time

You can customize various Data Source and Report Wizard options at design time using the DataSourceWizardSettings property. The SqlWizardSettings.AvailableDataProviders property allows you to select which data providers are displayed on the “Select a Data Connection Type” page.

The following XAML code demonstrates how to specify this setting:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:dxrud="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesigner" 
        xmlns:dxda="http://schemas.devexpress.com/winfx/2008/xaml/dataaccess"
        Title="MainWindow" >
    <dxrud:ReportDesigner DataSourceWizardSettings="{dxda:DataSourceWizardSettings 
            SqlWizardSettings={dxda:SqlWizardSettings AvailableDataProviders=MSSqlServer}}">
    </dxrud:ReportDesigner>
</Window>

Remove Data Providers at Runtime

The example customizes the Report Wizard and Data Source Wizard to achieve the following:

  • Display ChooseDataProviderPage (“Select a Data Connection Type”) as the start page.

  • Restrict available SQL data source providers to MSSQLServer, Oracle, Amazon Redshift, MySQL, Postgres, and SQLite.

wpf-report-wizard-removing-data-providers

View Example: Customize the Data Providers List

Customization Service

To customize Data Source and Report Wizards, create a customization service (MyWizardCustomizationService in this example) that implements the IWizardCustomizationService interface.

CustomizeDataSourceWizard and CustomizeReportWizard methods contain main logic for wizard customization:

  • StartPage - sets the initial wizard page to ChooseDataProviderPage (“Select a Data Connection Type”).
  • ReportType - specifies the report type in the report model.
  • DataSourceType - specifies the data source type in the report model.

The CustomizeProviders method limits available data source types and providers to a predefined list.

// ...
// Customization service for the Data Source and Report wizards.
public class MyWizardCustomizationService : IWizardCustomizationService {

    static readonly string[] allowedSqlDataSourceProviders = new[] {
        "MSSqlServer", "Oracle", "Amazon Redshift", "MySql", "Postgres", "SQLite"
    };
    // Modifies the Data Source wizard's start page and data source type. 
    void IDataSourceWizardCustomizationService.CustomizeDataSourceWizard(DataSourceWizardCustomizationModel customization, ViewModelSourceIntegrityContainer container) {
        if(customization.StartPage == typeof(ChooseExistingConnectionPage<IDataSourceModel>)) {
            customization.Model.DataSourceType = DataSourceType.Xpo;
            customization.StartPage = typeof(ChooseDataProviderPage<IDataSourceModel>);
        }
        CustomizeProviders(container);
    }
    // Modifies the Report wizard's start page, data source type, and report type.
    void IWizardCustomizationService.CustomizeReportWizard(ReportWizardCustomizationModel customization, ViewModelSourceIntegrityContainer container) {
        if (customization.StartPage == typeof(ChooseReportTypePage<XtraReportModel>)) {
            customization.Model.ReportType = ReportType.Standard;
            customization.Model.DataSourceType = DataSourceType.Xpo;
            customization.StartPage = typeof(ChooseDataProviderPage<XtraReportModel>);
        }
        CustomizeProviders(container);
    }
    // ...
    // Filters available SQL data source providers and registers allowed providers in the container.
    static void CustomizeProviders(IntegrityContainer container) {
        var providers = container.Resolve<List<ProviderLookupItem>>();
        providers.RemoveAll(x => !allowedSqlDataSourceProviders.Contains(x.ProviderKey));
        container.RegisterInstance<DataSourceTypes>(new DataSourceTypes(WizardDataSourceType.Sql));
    }
}

Service Registration

The ReportDesigner.ServicesRegistry property registers the MyWizardCustomizationService type in XAML and applies customization logic.

<dxrud:ReportDesigner x:Name="reportDesigner">
    <dxrud:ReportDesigner.ServicesRegistry>
        <dxda:TypeEntry ServiceType="{x:Type dxrudw:IWizardCustomizationService}" ConcreteType="{x:Type local:MyWizardCustomizationService}" />
    </dxrud:ReportDesigner.ServicesRegistry>
</dxrud:ReportDesigner>
See Also