Capoala.MVVM 2017.1.2.5

Additional Details

This project is no longer actively maintained.

There is a newer version of this package available.
See the version list below for details.
dotnet add package Capoala.MVVM --version 2017.1.2.5
NuGet\Install-Package Capoala.MVVM -Version 2017.1.2.5
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="Capoala.MVVM" Version="2017.1.2.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Capoala.MVVM --version 2017.1.2.5
#r "nuget: Capoala.MVVM, 2017.1.2.5"
#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 Capoala.MVVM as a Cake Addin
#addin nuget:?package=Capoala.MVVM&version=2017.1.2.5

// Install Capoala.MVVM as a Cake Tool
#tool nuget:?package=Capoala.MVVM&version=2017.1.2.5

Capoala.MVVM

Capoala.MVVM is a featherlight MVVM framework designed for simple-to-moderate MVVM design pattern applications. This framework includes basic implementations for handling property notifications, command bindings, and navigation.

INotifyPropertyChanged

NotifyingObjectBaseSlim

The NotifyingObjectBaseSlim class is a slim, standard INotifyPropertyChanged implementation. A streamlined method named SetAndNotify() will set the referenced property's value and raise the PropertyChanged event in one swell swoop.

public class ViewModel : Capoala.MVVM.NotifyingObjectBaseSlim
{
    string _name = null;
    public string Name { get => _name; set => SetAndNotify(ref _name, value); }
}

In cases where extra work or additional notifications are required, you can use standard getter setter syntax and utilize the Notify() method to raise the PropertyChanged event on the property being set.

public class ViewModel : Capoala.MVVM.NotifyingObjectBaseSlim
{
    string _firstName = null;
    public string FirstName
    {
        get => _firstName;
        set
        {
            _firstName = value;
            Notify();
            Notify(nameof(FullName));
        }
    }

    string _lastName = null;
    public string LastName
    {
        get => _lastName;
        set
        {
            if (SetAndNotify(ref _lastName, value))
                Notify(nameof(FullName));
        }
    }

    public string FullName => $"{FirstName} {LastName}";
}

NotifyingObjectBase

The NotifyingObjectBase class is a more feature-rich implementation of the INotifyPropertyChanged interface. This class removes the requirement of a backing field and moves it into a backing store in the form of a Dictionary<string, object>.

This class also provides an attribute approach to streamlining property notification dependencies. In the below example, the property FullName subscribes to the FirstName and LastName event changes. When either FirstName or LastName is changed, FullName is also notified.

public class ViewModel : Capoala.MVVM.NotifyingObjectBase
{
    public string FirstName { get => Get<string>(); set => Set(value); }
    public string LastName { get => Get<string>(); set => Set(value); }

    [NotifiedOnChange(nameof(FirstName), nameof(LastName))]
    public string FullName => $"{FirstName} {LastName}";
}

ICommand

RelayCommand

The RelayCommand implements the ICommand interface and comes in two flavors; RelayCommand and RelayCommand<T> for passing command paramters.

using Capoala.MVVM;
using DW = System.Diagnostics.Debug;

public class ViewModel
{
    public RelayCommand SaveCommand { get; } 
        = new RelayCommand(() => DW.WriteLine("Saving..."));

    public RelayCommand<string> GetRecordCommand { get; } 
        = new RelayCommand<string>(entryName => DW.WriteLine(entryName));
}
...
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <TextBox x:Name="RecordID"/>
    <Button Grid.Column="1" 
            Margin="10 0 0 0" 
            Command="{Binding GetRecordCommand}" 
            CommandParameter="{Binding ElementName=RecordID, Path=Text}">Retreive</Button>
</Grid>
<Grid Grid.Row="1" Margin="0 20 0 0">
    
</Grid>
<Grid Grid.Row="2" Margin="0 20 0 0">
    <Button HorizontalAlignment="Right" 
            Command="{Binding SaveCommand}">Save</Button>
</Grid>
...

A simplistic navigation implementation is also available which should satisfy most requirements. The navigation system includes an INavigationService<TNavigationItem> interface, and a NavigationServiceBase<TNavigationItem> base class.

using Capoala.MVVM;

public static class NavigationHelper
{
    public static INavigationService<object> Navigator { get; } 
        = new DefaultNavigationService();
}

public class ViewModel { }

public class MainViewModel : NotifyingObjectBase
{
    public object CurrentViewModel { get => Get<object>(); set => Set(value); }

    public MainViewModel()
    {
        NavigationHelper.Navigator.NavigationDidHappen += (s, e) =>
        {
            CurrentViewModel = NavigationHelper.Navigator.Current;
        };

        NavigationHelper.Navigator.Navigate(new ViewModel());
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETFramework 4.7

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

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
2019.0.1 733 3/7/2019
2019.0.0-beta.3 331 3/3/2019
2019.0.0-alpha.4 326 3/2/2019
2019.0.0-alpha.3 309 3/1/2019
2019.0.0-alpha.2 303 2/28/2019
2019.0.0-alpha.1 302 2/27/2019
2017.1.2.5 1,050 11/28/2017
2017.1.1.3 1,380 11/19/2017

Release Notes 2017.1.2.5
The Set() and SetAndNotify() methods now return a boolean value for evaluating whether the property was set or not.
The Set() and SetAndNotify() methods now allow for a different equality comparer to be used.

Release Notes 2017.1.1.3
Provides default implementations of the INotifyPropertyChanged interface.
Provides default implementations of the ICommand interface.
Provides default implementations of a navigation service.