Make cross-platform app MVVM-Ready. Lightweight with only one small binary/file.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets/css
src
.gitignore
CHANGELOG.md
LICENSE
README.md
_config.yml
appveyor.yml

README.md

NuGet NuGet Build status

About

Make cross-platform app MVVM-Ready. Lightweight with only one small binary/file.

Installation

Get MvvmReady library from NuGet.

PM> Install-Package MvvmReady

Features

Command

It's a simple ICommand implementation. Here is an example:

public ICommand HelloWorldCommand => new Command(() =>
{
    Debug.WriteLine("Hello, world!");
});

ViewModelBase

It's an abstract base class for ViewModels.

Use Set(ref variable, value) to set value and trigger PropertyChanged event.

Use RaisePropertyChanged() to trigger PropertyChanged event for current property.

Here is an example:

public class ProfileViewModel: ViewModelBase
{
    private string _name;
    public string Name
    {
        get => _name;
        set => Set(ref _name, value);
    }
    
    public int Age
    {
        get => DateTime.Now.Year - DateOfBirth.Year
    }
    
    private DateTime _dateOfBirth;
    public DateTime DateOfBirth
    {
        get => _dateOfBirth;
        set
        {
            Set(ref _dateOfBirth, value);
            RaisePropertyChanged(nameof(Age));
        }
    }
    
}

ServiceLocator

It's a simple service locator.

You can register interface to implementation by using ServiceLocator.Current.Register<IInterface, Implementation>().

You can also register service to itself by using ServiceLocator.Current.Register<Service>().

You can register a singleton service by using ServiceLocator.Current.Register<IInterface>(() => MyService.Instance).

To get service object, use ServiceLocator.Current.Get<IService>().

License

This work is licensed under MIT.