AlexBins.Hosting.Wpf 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AlexBins.Hosting.Wpf --version 1.0.0                
NuGet\Install-Package AlexBins.Hosting.Wpf -Version 1.0.0                
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="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AlexBins.Hosting.Wpf --version 1.0.0                
#r "nuget: AlexBins.Hosting.Wpf, 1.0.0"                
#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=1.0.0

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

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 {
  [STAThread]
  static int Main(string[] args) {
    var hostBuilder = new HostBuilder();
    hostBuilder.ConfigureWpf(svc =>
    {
        svc.AddSingleton(_ => new Window { Title = "My first Test Window" });
        svc.AddSingleton(_ => new Window { Title = "My second Test Window" });
    });
    return hostBuilder.RunWpf(CancellationToken.None);
  }
}

Why no async support?

A WPF application has to be started from a STA thread since many UI components require this. I have not investigated if it is possible to do so from an async context, but not using it has definitely been an easy solution. Any hosted services configured will work as usual.

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed. 
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 150 4/8/2024
2.1.0 131 3/11/2024
2.0.0 126 3/11/2024
1.0.0 277 8/22/2022 1.0.0 is deprecated because it is no longer maintained.