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.
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 wizard start page toChooseDataProviderPage
("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.
// ...
// Сustomization 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));
}
}
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>
- MainWindow.xaml (VB: MainWindow.xaml)
- MyWizardCustomizationService.cs (VB: MyWizardCustomizationService.vb)
(you will be redirected to DevExpress.com to submit your response)