Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/junian/mvvmready

Make cross-platform app MVVM-Ready. Lightweight with only one small binary/file.
https://github.com/junian/mvvmready

cross-platform mvvm mvvm-ready nuget

Last synced: 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

MvvmReady Logo

MvvmReady

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


MvvmReady on GitHub
MvvmReady latest version on NuGet
MvvmReady total downloads on NuGet

----

## Installation

Get [MvvmReady](http://www.nuget.org/packages/MvvmReady) library from NuGet.

```powershell
dotnet add package MvvmReady
```

## Features

### Command

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

```csharp
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:

```csharp
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()`.

You can also register service to itself by using `ServiceLocator.Current.Register()`.

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

To get service object, use `ServiceLocator.Current.Get()`.

## License

This work is licensed under [MIT](https://github.com/junian/mvvmready/blob/master/LICENSE).