NuExt.Minimal.Mvvm.Sources
0.1.2
dotnet add package NuExt.Minimal.Mvvm.Sources --version 0.1.2
NuGet\Install-Package NuExt.Minimal.Mvvm.Sources -Version 0.1.2
<PackageReference Include="NuExt.Minimal.Mvvm.Sources" Version="0.1.2" />
paket add NuExt.Minimal.Mvvm.Sources --version 0.1.2
#r "nuget: NuExt.Minimal.Mvvm.Sources, 0.1.2"
// Install NuExt.Minimal.Mvvm.Sources as a Cake Addin #addin nuget:?package=NuExt.Minimal.Mvvm.Sources&version=0.1.2 // Install NuExt.Minimal.Mvvm.Sources as a Cake Tool #tool nuget:?package=NuExt.Minimal.Mvvm.Sources&version=0.1.2
NuExt.Minimal.Mvvm
NuExt.Minimal.Mvvm
is a lightweight MVVM (Model-View-ViewModel) framework designed to provide the essential components needed for implementing the MVVM pattern in .NET applications. This package focuses on supporting proper concurrent operations and does not have any external dependencies, making it easy to integrate and use in various projects.
Features
Command Implementations:
Minimal.Mvvm.RelayCommand
: A simple command implementation that delegates its execution logic via delegates.Minimal.Mvvm.RelayCommand<T>
: A relay command that operates with generic parameters.
Asynchronous Command Support:
Minimal.Mvvm.AsyncCommand
: An asynchronous command that facilitates non-blocking operations without parameters.Minimal.Mvvm.AsyncCommand<T>
: An asynchronous command capable of handling operations with generic parameters.
Simplified Model Development:
Minimal.Mvvm.BindableBase
: A base class that implementsINotifyPropertyChanged
, simplifying property change notification in models.
ViewModels Development:
Minimal.Mvvm.ViewModelBase
: A base class for ViewModels, providing a foundation for building complex view models.
Concurrent Command Execution:
- All
IRelayCommand
command types (RelayCommand
,RelayCommand<T>
,AsyncCommand
,AsyncCommand<T>
) support concurrent executions. This allows multiple invocations of the same command simultaneously without interfering with other executions.
- All
CompositeCommand Implementation:
Minimal.Mvvm.CompositeCommand
: Represents a command that aggregates multiple commands and executes them sequentially. This is useful when you need to perform a series of actions as a single command operation.
Installation
You can install NuExt.Minimal.Mvvm
via NuGet:
dotnet add package NuExt.Minimal.Mvvm
Or through the Visual Studio package manager:
- Go to
Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution...
. - Search for
NuExt.Minimal.Mvvm
. - Click "Install".
Source Code Package
In addition to the standard package, there is also a source code package available: NuExt.Minimal.Mvvm.Sources
. This package allows you to embed the entire framework directly into your application, enabling easier source code exploring and debugging.
To install the source code package, use the following command:
dotnet add package NuExt.Minimal.Mvvm.Sources
Or through the Visual Studio package manager:
- Go to
Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution...
. - Search for
NuExt.Minimal.Mvvm.Sources
. - Click "Install".
Usage
Example Using AsyncCommand with CancellationTokenSource Support
public class MyViewModel : ViewModelBase
{
public IAsyncCommand MyCommand { get; }
public ICommand CancelCommand { get; }
public MyViewModel()
{
MyCommand = new AsyncCommand(ExecuteAsync, CanExecute);
CancelCommand = new RelayCommand(ExecuteCancel, CanCancel);
}
private async Task ExecuteAsync()
{
// Retrieve the CancellationTokenSource for current execution method instance
var cts = MyCommand.CancellationTokenSource;
try
{
// Command execution logic
await Task.Delay(1000, cts.Token);
}
catch (OperationCanceledException)
{
// Handle cancellation
}
}
private bool CanExecute()
{
// Logic that determines whether the command can execute
return true;
}
private void ExecuteCancel()
{
// Sends request to cancel the MyCommand execution
MyCommand.Cancel();
}
private bool CanCancel()
{
// Logic that determines whether the cancel command can execute
return MyCommand.IsExecuting;
}
}
Example Using BindableBase
public class MyModel : BindableBase
{
private string _name;
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
}
Contributing
Contributions are welcome! Feel free to submit issues, fork the repository, and send pull requests. Your feedback and suggestions for improvement are highly appreciated.
License
Licensed under the MIT License. See the LICENSE file for details.
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.2
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net6.0
- No dependencies.
-
net8.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 |
---|---|---|
0.1.2 | 68 | 9/18/2024 |