VOOZH about

URL: https://www.nuget.org/packages/DSoft.System.Mvvm.UI.WPF

⇱ NuGet Gallery | DSoft.System.Mvvm.UI.WPF 3.6.2606.131




👁 Image
DSoft.System.Mvvm.UI.WPF 3.6.2606.131

dotnet add package DSoft.System.Mvvm.UI.WPF --version 3.6.2606.131
 
 
NuGet\Install-Package DSoft.System.Mvvm.UI.WPF -Version 3.6.2606.131
 
 
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="DSoft.System.Mvvm.UI.WPF" Version="3.6.2606.131" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DSoft.System.Mvvm.UI.WPF" Version="3.6.2606.131" />
 
Directory.Packages.props
<PackageReference Include="DSoft.System.Mvvm.UI.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 DSoft.System.Mvvm.UI.WPF --version 3.6.2606.131
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DSoft.System.Mvvm.UI.WPF, 3.6.2606.131"
 
 
#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 DSoft.System.Mvvm.UI.WPF@3.6.2606.131
 
 
#: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=DSoft.System.Mvvm.UI.WPF&version=3.6.2606.131
 
Install as a Cake Addin
#tool nuget:?package=DSoft.System.Mvvm.UI.WPF&version=3.6.2606.131
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

System.Mvvm.UI.WPF

Provides WPF (.NET Framework 4.6.2 and .NET 10 and above) platform implementations for DSoft.System.Mvvm.UI

Functionality

  • Core UI functions for Showing Alerts and Confirmation Dialogs
  • UI Thread execution
  • Dependency injection support with IPlatformCoreUIProvider
  • Works with (.NET Framework 4.6.2 and .NET 10 and above)
    • Windows 7 and above

Support for .NET 10 and above with Windows 10/11

There are two Target Framework Monikers (TFMs) that are supported for Windows 10 and above when using .NET 10 or above, depending on if your application is using the Windows 10/11 SDK.

  • net10.0-windows7.0
    • Works with Windows 7, 8, 8.1, 10 and 11
  • net10.0-windows10.0.18362.0
    • Works with Windows 10 1903 (18362) and above only to access the Windows 10/11 SDK

Using System.Mvvm.UI.WPF

The UI static class provides four methods as defined in the IPlatformCoreUIProvider interface.

  • A central interface for calling some simple UI functions
    • ShowAlert(string title, string message)
      • Show an alert with a title and message using the platform implementation
    • ShowConfirmation(string title, string message)
      • Show a confirmation dialog and return the result using the platform implementation
    • InvokeOnUIThread(Action)
      • Execute the action on the UI thread using the platform implementation
    • InvokeOnUIThreadAsync(Action)
      • Execute the action on the UI thread asyncronously using the platform implementation

The standard UI functions can be called directly after adding the DSoft.Mvvm.UI package to your shared code

using System.Mvvm;
... 

var result = await UI.ShowConfirmationDialogAsync("Confirm this", "This is a platform specific confirmation message");

if (result)
 await UI.ShowAlertAsync("YAY!", "You confirmed that");

In the WPF application project that contains the App class(or other sub-class of Application) to the application, add the DSoft.System.Mvvm.UI.WPF package.

Call the MvvmManager.Init method in the application code, such as App constructor.

using System.Mvvm;
... 
public partial class App : Application
{
 public App()
 {
 this.InitializeComponent();
 this.Suspending += OnSuspending;

 MvvmManager.Init();

 }
}

Dependency Injection

Instead of using the static UI class you can use dependency injection to access the platform implementation of IPlatformCoreUIProvider using extensions for IServiceCollection provided by the platform specific packages.

After adding DSoft.System.Mvvm.UI.WPF to the application project you can register the core UI implementations of IPlatformCoreUIProvider with the ServiceProvider during configuration of the services using the AddCoreUI extension method.

using System.Mvvm;
... 
public partial class App : Application
{
 public App()
 {
 ServiceHost.Host = new HostBuilder()
 .ConfigureServices(ConfigureServices)
 .Build();
 }

 void ConfigureServices(HostBuilderContext ctx, IServiceCollection services)
 {
 services.AddCoreUI();
 }
}

Once the core UI is registered you can use IPlatformCoreUIProvider with dependency injection in class constructors.

using System.Mvvm;
... 
public class SharedClassToDoThingsIn
{
 private readonly IPlatformCoreUIProvider _coreUIProvider;

 public SharedClassToDoThingsIn(IPlatformCoreUIProvider coreUIProvider)
 {
 _coreUIProvider = coreUIProvider;
 }

 public async Task SayHello()
 {
 await _coreUIProvider.ShowAlertAsync("Congrats", "You called the ICoreUIProvider instance");
 }
}

Use can also retrieve the implementation directly from the services provider or ServiceHost if you are using DSoft.System.Mvvm.Hosting

using System.Mvvm;
... 
var _coreUIProvider = ServiceHost.GetRequiredService<IPlatformCoreUIProvider>();

await _coreUIProvider.ShowAlertAsync("Congrats", "You called the ICoreUIProvider instance");

Using DI instead of the UI does not require a call to MvvmManager.Init though you do have to call the extension method to register the services. You can also use both.

IWPFPlatformUIProvider

IWPFPlatformUIProvider is a platform specific interface that the platform implementation of `` implements. It provides access to some additonal WPF properties.

  • CuurentApplication
  • CurrentDispatcher
  • CurrentWindow
  • CurrentWindowOfType<T>()

Use can retrieve the implementation directly from the services provider or ServiceHost if you are using DSoft.System.Mvvm.Hosting

using System.Mvvm;
... 

var _formsUIProvider = ServiceHost.GetRequiredService<IWPFPlatformUIProvider>();

var currentApp = _formsUIProvider.CurrentApplication;

Dialog overrides

IWPFPlatformUIProvider also provides the ability to override the default dialog implementations.

Two function properties are provided to set your own implementations, such as using Mahapps.

  • Func<string,string,Task>ShowAlertOverideFunction
  • Func<string,string,Task<bool>>ShowConfirmOverideFunction

You can set your own implementations by retrieving the IWPFPlatformUIProvider instance, either with UI.Provider<T> or from the service provicer instance, SystemHost.GetRequiredService<T> if you are using DSoft.System.Mvvm.Hosting, and then setting the relevant overrides.

Below is an example that override the default behaviour using MahApps.

using System.Mvvm;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
... 
 public partial class App : Application
{
 
 protected override async void OnStartup(StartupEventArgs e)
 {
 base.OnStartup(e);

 MvvmManager.Init();

 await ServiceHost
 .Initialize(ConfigureServices)
 .StartAsync();

 var wpfPlatform = ServiceHost.GetRequiredService<IWPFPlatformUIProvider>();

 wpfPlatform.ShowAlertOverideFunction = ShowAlertWindow;

 wpfPlatform.ShowConfirmOverideFunction = ShowConfirmationDialog;

 }

 public static Task ShowAlertWindow(string title, string message)
 {
 var wpfPlatform = ServiceHost.GetRequiredService<IWPFPlatformUIProvider>();

 var currentWindow = wpfPlatform.CurrentWindow as MetroWindow;

 return DialogManager.ShowMessageAsync(currentWindow, title, message);
 }

 public static Task<bool> ShowConfirmationDialog(string title, string message)
 {
 var tcs = new TaskCompletionSource<bool>();

 var wpfPlatform = ServiceHost.GetRequiredService<IWPFPlatformUIProvider>();

 UI.InvokeOnUIThread(async () =>
 {
 var currentWindow = wpfPlatform.CurrentWindow as MetroWindow;

 var result = await DialogManager.ShowMessageAsync(currentWindow, title, message, MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
 {
 AffirmativeButtonText = "Yes",
 NegativeButtonText = "No",
 });

 tcs.SetResult((result == MessageDialogResult.Affirmative));
 });
 

 return tcs.Task;
 }
}
Product Versions Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 net10.0-windows7.0 is compatible.  net10.0-windows10.0.18362 net10.0-windows10.0.18362 is compatible. 
.NET Framework net462 net462 is compatible.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 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
3.6.2606.131 87 6/13/2026
3.5.2604.111 135 4/11/2026
3.5.2511.161 350 11/16/2025
3.4.2511.61 258 11/6/2025
3.4.2506.231 357 6/23/2025
3.4.2411.191 497 11/19/2024
3.4.2406.251 342 6/25/2024
3.3.2405.241 297 5/24/2024
3.3.2405.21 290 5/5/2024
3.2.2301.91 1,342 1/9/2023
3.1.2208.151 1,203 8/15/2022
3.1.2205.231 1,299 5/23/2022
3.1.2205.52-beta1 769 5/5/2022
3.0.2202.121 1,237 2/12/2022
3.0.2111.271-prerelease 860 11/27/2021

Updated to .NET 10 and latest packages. Removed .NET 8 and .NET 9 support. Performance improvements.