Duraxium.Net.MVVM
1.0.0
dotnet add package Duraxium.Net.MVVM --version 1.0.0
NuGet\Install-Package Duraxium.Net.MVVM -Version 1.0.0
<PackageReference Include="Duraxium.Net.MVVM" Version="1.0.0" />
paket add Duraxium.Net.MVVM --version 1.0.0
#r "nuget: Duraxium.Net.MVVM, 1.0.0"
// Install Duraxium.Net.MVVM as a Cake Addin #addin nuget:?package=Duraxium.Net.MVVM&version=1.0.0 // Install Duraxium.Net.MVVM as a Cake Tool #tool nuget:?package=Duraxium.Net.MVVM&version=1.0.0
Duraxium .NET MVVM Library
Version | Notes |
---|---|
1.0.0 | Origination. |
Fundamental view model, command, and converter classes for .NET MVVM implementations.
BaseViewModel
An abstract base view model from which to derive application view models. This class is similar to the Prism BindableBase class. It provides one event and three methods –
public event PropertyChangedEventHandler PropertyChanged;
The PropertyChanged event – triggered whenever a property value is changed.
protected void RaisePropertyChanged(string propertyName)
Raise/trigger the PropertyChanged event.
propertyName – the name of the property whose value has changed. If propertyName is omitted, the name of the calling property is used.
protected virtual bool SetProperty<T>(ref T propertyField, T value, string propertyName)
Set the value of a property and, if changed, trigger the PropertyChanged event.
T – the property type
propertyField – the backing field used by the property.
value – the new property value.
propertyName – the optional property name. If propertyName is omitted, the name of the calling property is used.
Returns true if the property value changed, else false.
protected virtual bool SetProperty<T>(ref T propertyField, T value, Action onChanged, string propertyName)
Set the value of a property and, if changed, trigger the PropertyChanged event and call the specified callback method (action).
T – the property type
propertyField – the field used by the property.
value – the new property value.
onChanged – the callback method to be called whenever the property value is changed.
propertyName – the optional property name. If propertyName is omitted, the name of the calling property is used.
Returns true if the property value changed, else false.
SyncCommand
A WPF ICommand implementation that executes a callback method synchronously. It provides one event and one constructor –
public event EventHandler CanExecuteChanged;
The CanExecuteChanged event, triggered whenever an action affects whether the command can execute.
public SyncCommand(Action<object> action, Func<bool> canExecute)
SyncCommand constructor
action – the callback method executed when the command is executed.
canExecute – the function that determines whether the command can execute.
AsyncCommand
A WPF ICommand implementation that executes a callback method asynchronously. It provides one event and two constructors –
public event EventHandler CanExecuteChanged;
Triggered whenever the ability of the command to execute has changed.
public AsyncCommand(Action<object> action, bool disable, Action<Exception> lastChance)
AsyncCommand constructor.
action – the callback method for the command.
disable – if true, the commanding control (usually a button or menu item) is automatically disabled during execution to prevent overlapping invocations.
lastChance – a callback method that is called if exceptions are not caught in the command’s callback method (i.e. this method is a “last chance” exception handler).
public AsyncCommand(Action<object> action, Func<bool> canExecute, Action<Exception> lastChance)
AsyncCommand constructor.
action – the callback method for the command.
canExecute – a callback method used to determine if the command can be executed. The method must return true if the command can be executed, otherwise false.
lastChance – a callback method that is called if exceptions are not caught in the command’s callback method (i.e. this method is a “last chance” exception handler).
If the same callback method is assigned to more than one AsyncCommand instance, the method will be called N times sequentially rather than concurrently to avoid overlapping execution.
When multiple commands are executing concurrently, it is important for the command callback method(s) to use semaphores or other techniques to prevent shared resources from being corrupted.
It is best to catch exceptions within each command callback method to correctly handle and/or report them. Any exceptions not caught by the command callback method will be caught by the AsyncCommand instance that called it. If the AsyncCommand instance was assigned a “last chance” callback method, that method will be called when the exception is caught. If a “last chance” callback method was not assigned, the exception will be lost.
ByteArrayToImageConverter
A converter for converting a byte array to a BitmapImage for display. It does not use a command parameter.
ColorToBrushConverter
A converter for converting from a color to a solid color brush. It does not use a command parameter.
InverseBooleanConverter
A converter that inverts a Boolean value. It does not use a command parameter.
InverseBooleanToVisibilityConverter
A converter that converts an (inverse) Boolean value to a Visibility value. It uses an optional command parameter.
If the Boolean value is false, the value Visibility.Visible is returned.
If the Boolean value is true and the converter parameter is ‘NoCollapse’, the value Visibility.Hidden is returned.
If the Boolean value is true and the converter parameter is NOT ‘NoCollapse’, the value Visibility.Collapsed is returned.
BooleanOrConverter
A multi-converter that converts multiple Boolean inputs to a single Boolean output. The Boolean output will be true if any of the Boolean inputs is true.
BooleanAndConverter
A multi-converter that converts multiple Boolean inputs to a single Boolean output. The Boolean output will be true only if all of the Boolean inputs is true.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net7.0-windows7.0 is compatible. net8.0-windows was computed. net8.0-windows7.0 is compatible. net9.0-windows was computed. |
-
net6.0-windows7.0
- No dependencies.
-
net7.0-windows7.0
- No dependencies.
-
net8.0-windows7.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 |
---|---|---|
1.0.0 | 94 | 1/2/2025 |