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
<PackageReference Include="Extensions.Hosting.Wpf" Version="4.0.0" />
<PackageVersion Include="Extensions.Hosting.Wpf" Version="4.0.0" />
<PackageReference Include="Extensions.Hosting.Wpf" />
paket add Extensions.Hosting.Wpf --version 4.0.0
#r "nuget: Extensions.Hosting.Wpf, 4.0.0"
#:package Extensions.Hosting.Wpf@4.0.0
#addin nuget:?package=Extensions.Hosting.Wpf&version=4.0.0
#tool nuget:?package=Extensions.Hosting.Wpf&version=4.0.0
Microsoft.Extensions.Hosting.Wpf
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
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
- HostingSimple: A minimalistic, beginner-friendly introduction. Offers a basic starting point for understanding the framework.
- HostingReactiveUI: An advanced example using NLog for logging, ReactiveUI as the MVVM framework, and the TrayIcon feature.
- HostingReactiveUISimpleInjector: Incorporates SimpleInjector alongside ReactiveUI. Demonstrates that you're not limited to
Microsoft.DependencyInjection. - HostingReactiveUISimpleInjectorAmbientScope: Demonstrates
AsyncScopedLifestylewith SimpleInjector for ambient-scoping and integrates Threading. - HostingReactiveUISimpleInjectorFlowingScope: Demonstrates
ScopedLifestyle.Flowingwith SimpleInjector for closure-scoping. Presents an alternative approach withoutViewModelLocatorHost.
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.
- Getting Started — Minimal setup guide
- ViewModelLocator Feature — Bind DataContext in XAML via DI
- Constructor Injection in App — Inject services into your App class
- Threading — Switch between UI and background threads
- TrayIcon — System tray icon support
- Bootstrap (3rd-party DI) — SimpleInjector, Autofac, and other DI containers
- Architecture & How It Works — Internal architecture and lifecycle
- API Reference — Complete API reference
- FAQ & Troubleshooting — Common questions and error solutions
| Product | Versions 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. |
-
.NETCoreApp 3.1
- Microsoft.Extensions.Hosting (>= 6.0.0)
-
.NETFramework 4.6.2
- Microsoft.Extensions.Hosting (>= 6.0.0)
-
.NETFramework 4.8
- Microsoft.Extensions.Hosting (>= 6.0.0)
-
net10.0-windows7.0
- Microsoft.Extensions.Hosting (>= 6.0.0)
-
net6.0-windows7.0
- Microsoft.Extensions.Hosting (>= 6.0.0)
-
net7.0-windows7.0
- Microsoft.Extensions.Hosting (>= 6.0.0)
-
net8.0-windows7.0
- Microsoft.Extensions.Hosting (>= 6.0.0)
-
net9.0-windows7.0
- Microsoft.Extensions.Hosting (>= 6.0.0)
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.