Extensions.Hosting.Wpf 4.0.0

dotnet add package Extensions.Hosting.Wpf --version 4.0.0
                    
NuGet\Install-Package Extensions.Hosting.Wpf -Version 4.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="Extensions.Hosting.Wpf" Version="4.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Extensions.Hosting.Wpf" Version="4.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Extensions.Hosting.Wpf" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Extensions.Hosting.Wpf --version 4.0.0
                    
#r "nuget: Extensions.Hosting.Wpf, 4.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.
#:package Extensions.Hosting.Wpf@4.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Extensions.Hosting.Wpf&version=4.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Extensions.Hosting.Wpf&version=4.0.0
                    
Install as a Cake Tool

Microsoft.Extensions.Hosting.Wpf

Nuget Nuget GitHub

Unofficial implementation of Microsoft.Extensions.Hosting for WPF. It is inspired by Dapplo and this extensions is focused only on WPF and doesn't have Plugins, SingleInstance etc features like Dapplo. It's main feature is to provide the ability to bind DataContext with ViewModels directly in XAML where the ViewModel gets resolved by DI. This library also has few extensions packages to add features like tray icon, thread switching between main thread and threadpool thread, 3rd party DI support.

Changelog | Wiki

NuGet Packages

Name Description Latest version
Extensions.Hosting.Wpf The main library, with Microsoft.Extensions.Hosting for WPF support. NuGet
Extensions.Hosting.Wpf.TrayIcon An extension enabling tray icon support. NuGet
Extensions.Hosting.Wpf.Threading An extension enabling thread switching between Main UI Thread and ThreadPool Thread via Microsoft.VisualStudio.Threading. NuGet
Extensions.Hosting.Wpf.Bootstrap An extension enabling easier bootstrap for 3rd-party DI containers. Requires an explicit Extensions.Hosting.Wpf reference as of 4.0.0. NuGet

Quick Start

1. Add IApplicationInitializeComponent to App.xaml.cs

public partial class App : Application, IApplicationInitializeComponent
{
}

2. Create Program.cs

public class Program
{
    public static void Main(string[] args)
    {
        using IHost host = CreateHostBuilder(args).Build();
        host.Run();
    }

    private static IHostBuilder CreateHostBuilder(string[] args)
    {
        return Host.CreateDefaultBuilder(args)
            .ConfigureServices(ConfigureServices);
    }

    private static void ConfigureServices(HostBuilderContext hostContext, IServiceCollection services)
    {
        services.AddWpf<App>();
    }
}

3. Update .csproj

<StartupObject>[Namespace].Program</StartupObject>

For the full guide including ViewModel Locator, constructor injection, and more, see the Wiki.

Samples

  1. HostingSimple: A minimalistic, beginner-friendly introduction. Offers a basic starting point for understanding the framework.
  2. HostingReactiveUI: An advanced example using NLog for logging, ReactiveUI as the MVVM framework, and the TrayIcon feature.
  3. HostingReactiveUISimpleInjector: Incorporates SimpleInjector alongside ReactiveUI. Demonstrates that you're not limited to Microsoft.DependencyInjection.
  4. HostingReactiveUISimpleInjectorAmbientScope: Demonstrates AsyncScopedLifestyle with SimpleInjector for ambient-scoping and integrates Threading.
  5. HostingReactiveUISimpleInjectorFlowingScope: Demonstrates ScopedLifestyle.Flowing with SimpleInjector for closure-scoping. Presents an alternative approach without ViewModelLocatorHost.

Documentation

Full documentation is available in the Wiki:

Extensions.Hosting.Wpf.Bootstrap no longer includes Extensions.Hosting.Wpf transitively starting with 4.0.0, so bootstrap consumers must install both packages explicitly.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net6.0-windows7.0 is compatible.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net7.0-windows7.0 is compatible.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net9.0-windows7.0 is compatible.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net10.0-windows7.0 is compatible. 
.NET Core netcoreapp3.1 is compatible. 
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Extensions.Hosting.Wpf:

Package Downloads
Extensions.Hosting.Wpf.Threading

Adds Microsoft.VisualStudio.Threading support for Extensions.Hosting.Wpf

Extensions.Hosting.Wpf.TrayIcon

Adds tray icon for Extensions.Hosting.Wpf

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.0 111 8/17/2026
3.4.0 2,016 11/23/2023
3.3.0 887 3/8/2023
3.2.0 768 2/7/2023
3.1.0 813 1/26/2023
3.0.0 1,280 6/24/2022
2.0.0 1,060 6/8/2022
1.0.0 839 6/5/2022