AlexBins.Hosting.Wpf 2.1.1

dotnet add package AlexBins.Hosting.Wpf --version 2.1.1
NuGet\Install-Package AlexBins.Hosting.Wpf -Version 2.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AlexBins.Hosting.Wpf" Version="2.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AlexBins.Hosting.Wpf --version 2.1.1
#r "nuget: AlexBins.Hosting.Wpf, 2.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AlexBins.Hosting.Wpf as a Cake Addin
#addin nuget:?package=AlexBins.Hosting.Wpf&version=2.1.1

// Install AlexBins.Hosting.Wpf as a Cake Tool
#tool nuget:?package=AlexBins.Hosting.Wpf&version=2.1.1

Hosting.Wpf

What is it used for?

This library adds WPF support to Microsoft.Extensions.Hosting.

How do I use it?

You configure your host to use WPF and add Window instances as required. Then you use the provided extension method to run the application.

class Program {
  
  static int Main(string[] args) {
    var builder = new HostBuilder()
        .AddWpf<App>()
        .UseSerilog((ctx, svc, config) =>
            config
            .WriteTo.Console()
            .Enrich.FromLogContext()
            .MinimumLevel.Debug())
        .ConfigureServices((ctx, svc) =>
        {
            // Services registered as Window will be shown on app start
            svc.AddSingleton<Window, MainWindow>();
        });

    var host = builder.Build();
    var logger = host.Services.GetRequiredService<ILogger<Program>>();
    try
    {
        await host.RunAsync();
    }
    catch (Exception ex)
    {
        logger.LogCritical(ex, "Host terminated unexpectedly");
        return -1;
    }
    return 0;
  }
}
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.1 48 4/8/2024
2.1.0 87 3/11/2024
2.0.0 87 3/11/2024
1.0.0 235 8/22/2022