NuExt.Minimal.Mvvm.MahApps.Metro is a NuGet package that provides extensions for integrating MahApps.Metro, a popular Metro-style UI toolkit for WPF applications, with NuExt.Minimal.Mvvm.Wpf, a WPF extension for the lightweight MVVM framework NuExt.Minimal.Mvvm. This package includes services and components to facilitate the creation of modern, responsive, and visually appealing user interfaces using the MVVM pattern.
- Async dialogs (MahApps) — MVVM‑friendly
IAsyncDialogServicethat shows Metro dialogs and returnsUICommand/MessageBoxResultwithout UI thread blocking. - Tabbed documents (MetroTabControl) — a document manager that hosts view + VM in Metro tabs with an explicit, async lifecycle and clean disposal.
- Fits the Minimal MVVM WPF layer — services are dispatcher‑safe and play well with NuExt.Minimal.Mvvm.Wpf window/document patterns.
Requires MahApps.Metro (add resource dictionaries to
App.xamland useMetroWindow).
Add MahApps resource dictionaries to App.xaml and use MetroWindow as the base for your main window (per MahApps docs). 2
<!-- App.xaml -->
<Application ...>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps resource dictionaries -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<!-- Pick a theme -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application><!-- MainWindow.xaml -->
<mah:MetroWindow
x:Class="MyApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
Title="MyApp" Width="900" Height="600"
WindowStartupLocation="CenterScreen">
<!-- content -->
</mah:MetroWindow><!-- attach the MahApps-backed dialog service on a window -->
<nx:Interaction.Behaviors xmlns:nx="http://schemas.nuext.minimal/xaml">
<nx:DialogCoordinatorService x:Name="DialogCoordinatorService"/>
<nx:MetroDialogService x:Name="Dialogs"
DialogCoordinator="{Binding Source={x:Reference DialogCoordinatorService}}" />
</nx:Interaction.Behaviors>// ViewModel (NuExt.Minimal.Mvvm.Wpf base)
private IAsyncDialogService Dialogs => GetService<IAsyncDialogService>("Dialogs");
public async Task AskAsync(CancellationToken ct)
{
await using var viewModel = new ConfirmViewModel();
var result = await Dialogs.ShowDialogAsync(
MessageBoxButton.OKCancel,
title: "Confirm",
documentType: "MyDialogView",
viewModel: viewModel,
parentViewModel: this,
parameter: null,
cancellationToken: ct);
if (result != MessageBoxResult.OK) return;
// proceed...
} <mah:MetroTabControl>
<nx:Interaction.Behaviors xmlns:nx="http://schemas.nuext.minimal/xaml">
<nx:MetroTabbedDocumentService x:Name="Tabs" CloseButtonEnabled="True"
ActiveDocument="{Binding ActiveDocument}"
FallbackViewType="{x:Type views:ErrorView}">
</nx:MetroTabbedDocumentService>
</nx:Interaction.Behaviors>
</mah:MetroTabControl>public IAsyncDocumentManagerService Tabs => GetService<IAsyncDocumentManagerService>("Tabs");
public async Task OpenCustomerAsync(CustomerModel model, CancellationToken ct)
{
var vm = new CustomerViewModel(model);
var doc = await Tabs.CreateDocumentAsync("CustomerView", vm, parentViewModel: this, parameter: null, ct);
doc.DisposeOnClose = true;
doc.Show();
}See the repo samples/MetroWpfApp for a runnable example.
Minimal.Mvvm.Wpf.DialogCoordinatorService: coordinates dialogs in MVVM scenarios.Minimal.Mvvm.Wpf.MetroDialogService:IAsyncDialogServicebacked by MahApps dialogs.Minimal.Mvvm.Wpf.MetroTabbedDocumentService: document manager for tabs (MetroTabControl).MahApps.Metro.Controls.Dialogs.MetroDialog: The class used for custom dialogs.
- WPF on .NET 8/9/10 and .NET Framework 4.6.2+
- Requires MahApps.Metro resources in App.xaml and MetroWindow as your window type.
Via NuGet:
dotnet add package NuExt.Minimal.Mvvm.MahApps.MetroOr via Visual Studio:
- Go to
Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution.... - Search for
NuExt.Minimal.Mvvm.MahApps.Metro. - Click "Install".
Nice to have: NuExt.Minimal.Mvvm.SourceGenerator to remove boilerplate in view‑models.
Issues and PRs are welcome. Keep changes minimal and performance-conscious.
MIT. See LICENSE.