DevExpressServiceCollectionExtensions.AddDevExpressBlazor(IServiceCollection, Action<GlobalOptions>) Method

Adds internal DevExpress Blazor services to the IServiceCollection collection and sets up DevExpress Blazor components’ global options.

Namespace: Microsoft.Extensions.DependencyInjection

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

public static void AddDevExpressBlazor(
    this IServiceCollection services,
    Action<GlobalOptions> configure = null
)

Parameters

Name Type Description
services IServiceCollection

A IServiceCollection object that specifies the service collection.

Optional Parameters

Name Type Default Description
configure Action<GlobalOptions>

null

A delegate method that configures global options for DevExpress Blazor components.

Remarks

The AddDevExpressBlazor method is used to configure DevExpress Blazor services for your Blazor application. The DevExpress.Blazor NuGet package automatically adds this method to Blazor Server projects.

For Blazor WebAssembly projects, call the AddDevExpressBlazor method from your project’s Program.Main() method and pass global option values to this method (optional):

using Microsoft.Extensions.DependencyInjection;

public class Program {
    public static async Task Main(string[] args) {
        ...
        builder.Services.AddDevExpressBlazor();
        // builder.Services.AddDevExpressBlazor((options) => options.SizeMode = SizeMode.Medium); 
        await builder.Build().RunAsync();
    }
}

To specify DevExpress Blazor components’ global options for Blazor Server applications, use the following code:

using Microsoft.Extensions.DependencyInjection;

class Startup {
    public void ConfigureServices(IServiceCollection services) {
        ...
        services.AddDevExpressBlazor((options) => options.SizeMode = SizeMode.Medium);
    }
}
See Also