Skip to content

Dependency Injection

Simnico99 edited this page Oct 19, 2022 · 3 revisions

Contents

  1. Prerequesite
  2. Usage
  3. Result

Prerequesite

You will need to install the MicaWPF.DependencyInjection NuGet Package.

NuGet

  1. Download via the Nuget package manager or use the NuGet Command line.
    Install-Package MicaWPF.DependencyInjection 
  2. If you have used the NuGet Command line restore de packages.
    nuget restore ProjectName.sln

Usage

It is easy to implement just add .UseMicaWPF() to your IHostBuilder.

//Without Options
var builder = new HostBuilder();
builder.UseMicaWPF();

//With Options
var builder = new HostBuilder();
builder.UseMicaWPF(options => 
{
    options.AccentColor = Color.FromArgb(1, 255, 100, 100);
    options.Theme = WindowsTheme.Dark;
});

It allows you to access the IThemeService and IAccentService from dependency injection. See how to change theme or accent color.