Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/junian/mvvmready
- Owner: junian
- License: mit
- Created: 2018-02-09T09:23:46.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-25T22:11:23.000Z (3 months ago)
- Last Synced: 2024-12-03T08:50:45.402Z (2 months ago)
- Topics: cross-platform, mvvm, mvvm-ready, nuget
- Language: C#
- Homepage: https://www.junian.dev/mvvmready/
- Size: 46.9 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: docs/README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
MvvmReady
Make cross-platform app MVVM-Ready. Lightweight with only one small binary/file.
----
## 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).