PresentationBase.Core 3.6.0

.NET 6.0 .NET Standard 2.0
dotnet add package PresentationBase.Core --version 3.6.0
NuGet\Install-Package PresentationBase.Core -Version 3.6.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="PresentationBase.Core" Version="3.6.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PresentationBase.Core --version 3.6.0
#r "nuget: PresentationBase.Core, 3.6.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.
// Install PresentationBase.Core as a Cake Addin
#addin nuget:?package=PresentationBase.Core&version=3.6.0

// Install PresentationBase.Core as a Cake Tool
#tool nuget:?package=PresentationBase.Core&version=3.6.0

PresentationBase.Core Logo PresentationBase.Core

Azure DevOps builds (branch) Azure DevOps tests (branch) SonarCloud Quality Gate NuGet version NuGet downloads GitHub license

A lightweight MVVM implementation targeting .NET Standard 2.0 and .NET 6.0.

It contains base implementations for view models, commands, data transfer object conversion and more.

Examples

Take a look at the Quick start in the wiki. Here are some basic examples for using PresentationBase.Core:

ViewModels with bindable properties

public class AwesomeViewModel : ViewModel
{
    private string _name;
  
    public string Name
    {
        get => _name;
        set => SetProperty(ref _name, value);
    }
}

... and with property validation

public class AwesomeViewModel : ViewModel
{
    private string _name;

    public string Name
    {
        get => _name;
        set => SetProperty(ref _name, value, NameValidation);
    }

    private IEnumerable<string> NameValidation(string value)
    {
        if (string.IsNullOrEmpty(value))
            yield return "Name cannot be null or empty!";
        else if (value == "sungaila")
            yield return "Name cannot be stupid!";
    }
}

ViewModel collections

public class AwesomeViewModel : ViewModel
{
    public ObservableViewModelCollection<ChildViewModel> Children { get; }
    
    public AwesomeViewModel()
    {
        Children = new ObservableViewModelCollection<ChildViewModel>(this);
        Children.Add(new ChildViewModel { Nickname = "Blinky" });
        Children.Add(new ChildViewModel { Nickname = "Pinky" });
        Children.Add(new ChildViewModel { Nickname = "Inky" });
        Children.Add(new ChildViewModel { Nickname = "Clyde" });
    }
}

Commands

Your command can be defined anywhere you want (as long as its assembly is referenced by the application). Please note that a parameterless constructor (or none at all) is needed.

public class AlertCommand : ViewModelCommand<AwesomeViewModel>
{
    public override void Execute(AwesomeViewModel parameter)
    {
        System.Windows.MessageBox.Show("You just clicked that button.");
    }

    public override bool CanExecute(AwesomeViewModel parameter)
    {
        return parameter.Name != "John Doe";
    }
}

... and async commands

public class AlertCommandAsync : ViewModelCommandAsync<AwesomeViewModel>
{
    protected override async Task ExecutionAsync(AwesomeViewModel parameter)
    {
        await Task.Run(() =>
        {
            System.Threading.Thread.Sleep(2000);
            System.Windows.MessageBox.Show("You clicked that button two seconds ago.");
        });
    }
}
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PresentationBase.Core:

Package Downloads
PresentationBase

A lightweight MVVM implementation for WPF (Windows Presentation Foundation) targeting both .NET Framework and .NET.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.6.0 472 6/15/2022
3.5.0 340 11/27/2021
3.4.0 488 1/6/2021
3.4.0-preview 273 11/11/2020
3.3.0 490 9/20/2020
3.2.0 442 8/24/2020
3.1.3 506 6/26/2020
3.0.0 508 5/20/2020

- Make AddCommands and RemoveCommands accessible.
- Commands found via reflection now check the class inheritance properly.
- Add .NET 6.0 as target framework.