PsdFramework.ModularWpf
1.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package PsdFramework.ModularWpf --version 1.1.0
NuGet\Install-Package PsdFramework.ModularWpf -Version 1.1.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="PsdFramework.ModularWpf" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PsdFramework.ModularWpf" Version="1.1.0" />
<PackageReference Include="PsdFramework.ModularWpf" />
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 PsdFramework.ModularWpf --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PsdFramework.ModularWpf, 1.1.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 PsdFramework.ModularWpf@1.1.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=PsdFramework.ModularWpf&version=1.1.0
#tool nuget:?package=PsdFramework.ModularWpf&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PsdFramework.ModularWpf
ModularWpf is based off the CommunityToolkit.Mvvm package, a small framework library that helps with modulation in a WPF application.
Features
- IServiceCollection extensions that help with registering common models of the MVVM pattern:
AddView<TView, TViewModel>(),AddCachedView<TView, TViewModel>(),AddViewModel<TViewModel>()
Make sure to demand IView<TView> or IView<TView, TViewModel> but not the raw view object, otherwise the viewmodel will be not be bound to the view and you will just create a plain view.
- Modular Windows - you can assign a
Windowobject with aIModularWindowinterface, then await the window and get the result via the service
How to use
First lets define our window object:
public sealed partial class MyModularWindow : Window, IModularWindow
{
public MyModularWindow()
{
InitializeComponent();
}
}
Now lets register the window and the service
myServiceCollection.AddModularWindow<MyModularWindow>();
myServiceCollection.AddModularWindowsService();
// OR if you dont want to register each window manually:
myServiceCollection.AddModularWindows(assemblyFilter: a => a == typeof(MyModularWindow).Assembly)); // ! automatically registers the service as well !
Use-case
public sealed partial class MyViewModel : ObservableObject
{
private readonly IModularWindowsService _modularWindowsService;
public MyViewModel(IModularWindowsService modularWindowsService)
{
_modularWindowsService = modularWindowsService;
}
[RelayCommand]
private async Task OpenMyWindowAsync()
{
await _modularWindowsService.ShowWindowAsync<MyModularWindow>();
}
[RelayCommand]
private async Task OpenMyWindowWithResultAsync()
{
// string is a result type that is defined in the IModularWindow<TResult> interface
// regular IModularWindow doesnt have a return type, so in the implementation just keep it with the NotImplementedException
var result = await _modularWindowsService.ShowWindowAsync<MyModularWindow, string>();
Console.WriteLine(result);
}
}
| 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. net9.0-windows was computed. 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.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on PsdFramework.ModularWpf:
| Package | Downloads |
|---|---|
|
PsdFramework.ModularWpf.ExceptionHandling
Exception handling extensions for the PsdFramework.ModularWpf. |
GitHub repositories
This package is not used by any popular GitHub repositories.