Sanet.MVVM.Core 1.7.3

dotnet add package Sanet.MVVM.Core --version 1.7.3
                    
NuGet\Install-Package Sanet.MVVM.Core -Version 1.7.3
                    
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="Sanet.MVVM.Core" Version="1.7.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sanet.MVVM.Core" Version="1.7.3" />
                    
Directory.Packages.props
<PackageReference Include="Sanet.MVVM.Core" />
                    
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 Sanet.MVVM.Core --version 1.7.3
                    
#r "nuget: Sanet.MVVM.Core, 1.7.3"
                    
#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 Sanet.MVVM.Core@1.7.3
                    
#: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=Sanet.MVVM.Core&version=1.7.3
                    
Install as a Cake Addin
#tool nuget:?package=Sanet.MVVM.Core&version=1.7.3
                    
Install as a Cake Tool

Sanet.MVVM.Core

MVVM base classes and contracts for .NET 10.

Installation

dotnet add package Sanet.MVVM.Core

Minimal usage

using Sanet.MVVM.Core.ViewModels;

public sealed class MainViewModel : BaseViewModel
{
    private string _title = "Hello";

    public string Title
    {
        get => _title;
        set => SetProperty(ref _title, value);
    }

    public override void AttachHandlers()
    {
        // Subscribe to services or events.
    }

    public override void DetachHandlers()
    {
        // Unsubscribe here.
    }
}

BindableBase

BindableBase is an abstract base class that implements INotifyPropertyChanged. It exposes the following members to derived classes:

  • NotifyPropertyChanged([CallerMemberName] string? propertyName = null) raises PropertyChanged. It is protected virtual.
  • SetProperty<T>(ref T backingStore, T value, [CallerMemberName] string? propertyName = null) compares the current and new value with Equals, assigns the field, and raises PropertyChanged only when the value changes.
  • NotifyAllPropertiesChanged() raises PropertyChanged with an empty property name so that all bindings refresh.

BaseViewModel

BaseViewModel is abstract and derives from BindableBase.

  • IsBusy is a bindable busy flag.
  • BackCommand is an ICommand that calls INavigationService.NavigateBackAsync.
  • NavigationService returns the navigation service supplied to the constructor or to SetNavigationService. Accessing it before initialization throws ArgumentNullException.
  • Two protected constructors are available: a parameterless one and BaseViewModel(INavigationService navigationService).
  • SetNavigationService(INavigationService navigationService) initializes or replaces the navigation service after construction.
  • AttachHandlers() and DetachHandlers() are virtual hooks for subscribing and unsubscribing from services or events. The Avalonia base view calls them when the view enters or leaves the visual tree.

BaseViewModel does not implement IDisposable or IAsyncDisposable. Derived view models may add either interface when they need to release resources.

Contracts

  • IBaseView exposes an object? ViewModel { get; set; } property.
  • IBaseView<out TViewModel> is the typed variant used by BaseView<TViewModel>.
  • INavigationService defines navigation, back navigation, result-returning overlays, view registration, and AskForActionAsync.
  • IResultProvider<TResult> defines Task<TResult> GetResultAsync() for view models that return a result.
  • UiAction is a record with Title, an optional Command, and an optional CommandParameter.
  • IExternalNavigationService defines OpenUrlAsync(string url) and OpenEmailAsync(string emailAddress, string subject).

Notes and limitations

  • Sanet.MVVM.Core does not create a dependency-injection container and does not provide a navigation implementation. Use Sanet.MVVM.Navigation.Avalonia for Avalonia, or implement INavigationService yourself.
  • Always initialize NavigationService before a view model uses navigation.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (10)

Showing the top 5 NuGet packages that depend on Sanet.MVVM.Core:

Package Downloads
Sanet.MakaMek.Presentation

An Attempt of Classic BattleTech game implementation. Presentation Logic

Sanet.MakaMek.Avalonia.Controls

Avalonia UI controls for MakaMek

Sanet.MekForge.Core

An Attempt of Classic BattleTech game implementation. Game Logic

Sanet.MVVM.Navigation.Avalonia

Sanet MVVM Navigation implementation for Avalonia. Works with AvaloniaUI v12

Sanet.MVVM.Views.Avalonia

Avalonia BaseView for Sanet MVVM. Works with AvaloniaUI v12

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.7.3 99 11/24/2026
1.7.0 13,641 8/3/2026
1.6.0 2,738 7/14/2026
1.5.0 9,927 4/8/2026
1.4.0 6,360 10/23/2025
1.3.0 426 10/21/2025
1.2.0 1,032 10/14/2025
1.1.1 13,822 11/14/2023
1.1.0 520 8/13/2023
1.0.2 996 6/9/2023
1.0.1 357 6/2/2023
1.0.0 1,083 3/29/2023