Teckiv.Extensions.Hosting.Mvvm
1.1.8
dotnet add package Teckiv.Extensions.Hosting.Mvvm --version 1.1.8
NuGet\Install-Package Teckiv.Extensions.Hosting.Mvvm -Version 1.1.8
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="Teckiv.Extensions.Hosting.Mvvm" Version="1.1.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Teckiv.Extensions.Hosting.Mvvm" Version="1.1.8" />
<PackageReference Include="Teckiv.Extensions.Hosting.Mvvm" />
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 Teckiv.Extensions.Hosting.Mvvm --version 1.1.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Teckiv.Extensions.Hosting.Mvvm, 1.1.8"
#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 Teckiv.Extensions.Hosting.Mvvm@1.1.8
#: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=Teckiv.Extensions.Hosting.Mvvm&version=1.1.8
#tool nuget:?package=Teckiv.Extensions.Hosting.Mvvm&version=1.1.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
WPF extension library integrates with Microsoft.Extensions.Hosting and CommunityToolkit.Mvvm.
Application with main window
App.xaml.cs
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Teckiv.Extensions.Hosting.Mvvm.Wpf6.Views;
namespace Teckiv.Extensions.Hosting.Mvvm.Wpf6
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : HostedApplication<MainWindow>
{
protected override void ConfigureServices(HostBuilderContext context, IServiceCollection services)
{
services.AddSingleton<IMessenger>(StrongReferenceMessenger.Default);
}
}
}
App.xaml
<teckiv:HostedApplication x:Class="Teckiv.Extensions.Hosting.Mvvm.Wpf6.App"
x:TypeArguments="v:MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Teckiv.Extensions.Hosting.Mvvm.Wpf6"
xmlns:v="clr-namespace:Teckiv.Extensions.Hosting.Mvvm.Wpf6.Views"
xmlns:teckiv="clr-namespace:Teckiv.Extensions.Hosting.Mvvm;assembly=Teckiv.Extensions.Hosting.Mvvm">
<Application.Resources>
<SolidColorBrush x:Key="color" Color="Green"></SolidColorBrush>
</Application.Resources>
</teckiv:HostedApplication>
MainWindowViewModel.cs
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
namespace Teckiv.Extensions.Hosting.Mvvm.Wpf6.ViewModels
{
public partial class MainWindowViewModel : ObservableRecipient, IRecipient<ValueChangedMessage<DateTime>>
{
public MainWindowViewModel(IMessenger messenger) : base(messenger)
{
this.IsActive = true;
}
[ObservableProperty]
private DateTime currentTime;
public void Receive(ValueChangedMessage<DateTime> message)
{
this.CurrentTime = message.Value;
}
}
}
MainWindow.xaml.cs
using Teckiv.Extensions.Hosting.Mvvm.Views;
using Teckiv.Extensions.Hosting.Mvvm.Wpf6.ViewModels;
namespace Teckiv.Extensions.Hosting.Mvvm.Wpf6.Views
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : WindowBase<MainWindowViewModel>
{
public MainWindow(MainWindowViewModel mainWindowViewModel) : base(mainWindowViewModel)
{
InitializeComponent();
}
}
}
MainWindow.xaml
<teckiv:WindowBase x:Class="Teckiv.Extensions.Hosting.Mvvm.Wpf6.Views.MainWindow"
x:TypeArguments="vm:MainWindowViewModel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:teckiv="clr-namespace:Teckiv.Extensions.Hosting.Mvvm.Views;assembly=Teckiv.Extensions.Hosting.Mvvm"
xmlns:vm="clr-namespace:Teckiv.Extensions.Hosting.Mvvm.Wpf6.ViewModels"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" WindowState="Maximized">
<Grid>
<TextBlock Text="{Binding CurrentTime, StringFormat='HH:mm:ss.fff'}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" FontSize="120" FontWeight="Bold"></TextBlock>
</Grid>
</teckiv:Window>
Application with login dialog and main window
App.xaml.cs
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Teckiv.Extensions.Hosting.Mvvm.Wpf6.Views;
namespace Teckiv.Extensions.Hosting.Mvvm.Wpf6
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : HostedApplication<MainWindow, LoginDialog>
{
protected override void ConfigureServices(HostBuilderContext context, IServiceCollection services)
{
services.AddSingleton<IMessenger>(StrongReferenceMessenger.Default);
}
}
}
App.xaml
<teckiv:HostedApplication x:Class="Teckiv.Extensions.Hosting.Mvvm.Wpf6.App"
x:TypeArguments="v:MainWindow,v:LoginDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Teckiv.Extensions.Hosting.Mvvm.Wpf6"
xmlns:v="clr-namespace:Teckiv.Extensions.Hosting.Mvvm.Wpf6.Views"
xmlns:teckiv="clr-namespace:Teckiv.Extensions.Hosting.Mvvm;assembly=Teckiv.Extensions.Hosting.Mvvm">
<Application.Resources>
<SolidColorBrush x:Key="color" Color="Green"></SolidColorBrush>
</Application.Resources>
</teckiv:HostedApplication>
MainWindowViewModel.cs
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
namespace Teckiv.Extensions.Hosting.Mvvm.Wpf6.ViewModels
{
public partial class MainWindowViewModel : ObservableRecipient, IRecipient<ValueChangedMessage<DateTime>>
{
public MainWindowViewModel(IMessenger messenger) : base(messenger)
{
this.IsActive = true;
}
[ObservableProperty]
private DateTime currentTime;
public void Receive(ValueChangedMessage<DateTime> message)
{
this.CurrentTime = message.Value;
}
}
}
MainWindow.xaml.cs
using Teckiv.Extensions.Hosting.Mvvm.Views;
using Teckiv.Extensions.Hosting.Mvvm.Wpf6.ViewModels;
namespace Teckiv.Extensions.Hosting.Mvvm.Wpf6.Views
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : WindowBase<MainWindowViewModel>
{
public MainWindow(MainWindowViewModel mainWindowViewModel) : base(mainWindowViewModel)
{
InitializeComponent();
}
}
}
MainWindow.xaml
<teckiv:WindowBase x:Class="Teckiv.Extensions.Hosting.Mvvm.Wpf6.Views.MainWindow"
x:TypeArguments="vm:MainWindowViewModel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:teckiv="clr-namespace:Teckiv.Extensions.Hosting.Mvvm.Views;assembly=Teckiv.Extensions.Hosting.Mvvm"
xmlns:vm="clr-namespace:Teckiv.Extensions.Hosting.Mvvm.Wpf6.ViewModels"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" WindowState="Maximized">
<Grid>
<TextBlock Text="{Binding CurrentTime, StringFormat='HH:mm:ss.fff'}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" FontSize="120" FontWeight="Bold"></TextBlock>
</Grid>
</teckiv:Window>
LoginDialogViewModel.cs
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace Teckiv.Extensions.Hosting.Mvvm.Wpf6.ViewModels
{
public partial class LoginDialogViewModel : ObservableObject, INotifyDialogResultChanged
{
public event EventHandler<bool?> DialogResultChanged;
private void OnDialogResultChanged(bool? dialogResult)
{
this.DialogResultChanged?.Invoke(this, dialogResult);
}
[RelayCommand]
private void Success()
{
this.OnDialogResultChanged(true);
}
[RelayCommand]
private void Fail()
{
this.OnDialogResultChanged(false);
}
}
}
LoginDialog.xaml.cs
using Teckiv.Extensions.Hosting.Mvvm.Views;
using Teckiv.Extensions.Hosting.Mvvm.Wpf6.ViewModels;
namespace Teckiv.Extensions.Hosting.Mvvm.Wpf6.Views
{
public partial class LoginDialog : DialogBase<LoginDialogViewModel>
{
public LoginWindow(LoginDialogViewModel loginDialogViewModel) : base(loginDialogViewModel)
{
InitializeComponent();
}
}
}
LoginDialog.xaml
<teckiv:DialogBase x:Class="Teckiv.Extensions.Hosting.Mvvm.Wpf6.Views.LoginDialog"
x:TypeArguments="vm:LoginDialogViewModel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Teckiv.Extensions.Hosting.Mvvm.Wpf6.Views"
xmlns:teckiv="clr-namespace:Teckiv.Extensions.Hosting.Mvvm.Views;assembly=Teckiv.Extensions.Hosting.Mvvm"
xmlns:vm="clr-namespace:Teckiv.Extensions.Hosting.Mvvm.Wpf6.ViewModels"
mc:Ignorable="d"
Title="LoginWindow" Height="250" Width="450" WindowStyle="None">
<StackPanel>
<Button Content="Success" Command="{Binding SuccessCommand}"></Button>
<Button Content="Fail" Command="{Binding FailCommand}"></Button>
</StackPanel>
</teckiv:Dialog>
Service generate data
HeartbeatService
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using Microsoft.Extensions.Hosting;
namespace Teckiv.Extensions.Hosting.Mvvm.Wpf6.Services
{
public class HeartbeatService : BackgroundService
{
private readonly IMessenger messenger;
public HeartbeatService(IMessenger messenger)
{
this.messenger = messenger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
this.messenger.Send(new ValueChangedMessage<DateTime>(DateTime.Now));
await Task.Delay(TimeSpan.FromMilliseconds(10));
}
}
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. net8.0-windows7.0 is compatible. net9.0-windows was computed. net9.0-windows7.0 is compatible. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0-windows7.0
- CommunityToolkit.Mvvm (>= 8.4.2)
- Microsoft.Extensions.Hosting (>= 8.0.1)
-
net8.0-windows7.0
- CommunityToolkit.Mvvm (>= 8.4.2)
- Microsoft.Extensions.Hosting (>= 10.0.8)
-
net9.0-windows7.0
- CommunityToolkit.Mvvm (>= 8.4.2)
- Microsoft.Extensions.Hosting (>= 10.0.8)
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 |
|---|---|---|
| 1.1.8 | 113 | 5/13/2026 |
| 1.1.6 | 107 | 3/25/2026 |
| 1.1.5 | 107 | 3/25/2026 |
| 1.1.4 | 108 | 3/24/2026 |
| 1.1.3 | 102 | 3/20/2026 |
| 1.1.2 | 101 | 3/20/2026 |
| 1.1.1 | 105 | 3/3/2026 |
| 1.1.0 | 111 | 3/3/2026 |
| 1.0.9 | 108 | 2/28/2026 |
| 1.0.8 | 107 | 2/26/2026 |
| 1.0.7 | 107 | 2/25/2026 |
| 1.0.6 | 107 | 2/25/2026 |
| 1.0.5 | 122 | 1/29/2026 |
| 1.0.4 | 113 | 1/29/2026 |
| 1.0.3 | 131 | 1/28/2026 |
| 1.0.2 | 262 | 4/27/2025 |
| 1.0.1 | 208 | 4/27/2025 |
| 1.0.0 | 200 | 4/24/2025 |