Skip to main content
All docs
V26.1
  • IocServiceProvider.ConfigureServices(IServiceProvider) Method

    Configures the global IocServiceProvider using an IServiceProvider instance, which enables DevExpress MVVM components to resolve view models through dependency injection.

    Namespace: DevExpress.Mvvm

    Assembly: DevExpress.Mvvm.v26.1.dll

    Declaration

    public void ConfigureServices(
        IServiceProvider serviceProvider
    )

    Parameters

    Name Type Description
    serviceProvider IServiceProvider

    The application service provider instance.

    Remarks

    Call the ConfigureServices method once at application startup after building the dependency injection container. As a result, DevExpress MVVM components use the configured provider to resolve non-POCO view models.

    The following code snippet builds an application service provider and passes the provider to the IocServiceProvider.Default.ConfigureServices method so the DevExpress MVVM framework can get view models from the dependency injection container:

    var host = Host.CreateDefaultBuilder()
        .ConfigureServices(services =>
        {
            services.AddSingleton<MainViewModel>();
            services.AddTransient<CustomerViewModel>();
        })
        .Build();
    
    IocServiceProvider.Default.ConfigureServices(host.Services);
    

    See Also