JamSoft.Helpers.AvaloniaUI 1.2.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package JamSoft.Helpers.AvaloniaUI --version 1.2.2                
NuGet\Install-Package JamSoft.Helpers.AvaloniaUI -Version 1.2.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JamSoft.Helpers.AvaloniaUI" Version="1.2.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JamSoft.Helpers.AvaloniaUI --version 1.2.2                
#r "nuget: JamSoft.Helpers.AvaloniaUI, 1.2.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install JamSoft.Helpers.AvaloniaUI as a Cake Addin
#addin nuget:?package=JamSoft.Helpers.AvaloniaUI&version=1.2.2

// Install JamSoft.Helpers.AvaloniaUI as a Cake Tool
#tool nuget:?package=JamSoft.Helpers.AvaloniaUI&version=1.2.2                

JamSoft.Helpers.AvaloniaUI

A collection of general helpers for AvaloniaUI applications.

Table of Contents

Installation

Nuget

Install-Package JamSoft.Helpers.AvaloniaUI

CLI

dotnet add package JamSoft.Helpers.AvaloniaUI

Patterns

Mvvm ViewModelBase

A very bare bones view model with property changed updates

public abstract class AvaloniaViewModelBase : ReactiveObject
{
    private bool _isEditable;
    private bool _isBusy;
    
    /// <summary>
    /// Gets or sets a value indicating whether this instance is editable.
    /// </summary>
    /// <value>
    /// <c>true</c> if this instance is editable; otherwise, <c>false</c>.
    /// </value>
    public bool IsEditable
    {
        get => _isEditable;
        set => this.RaiseAndSetIfChanged(ref _isEditable, value);
    }

    /// <summary>
    /// Gets or sets the busy state for the view model instance
    /// </summary>
    public bool IsBusy
    {
        get => _isBusy;
        set => this.RaiseAndSetIfChanged(ref _isBusy, value);
    }
}

Mvvm ValidatableAvaloniaViewModelBase

/// <summary>
/// A base view model class for use in AvaloniaUI applications with validation 
/// </summary>
public class ValidatableAvaloniaViewModelBase : AvaloniaViewModelBase, IDirtyMonitoring
{
    private bool _isDirty;
    private IEnumerable<PropertyInfo>? _changedProperties;
    private IEnumerable<FieldInfo>? _changedFields;
    private string? _hash;

    /// <summary>
    /// Default ctor
    /// </summary>
    public ValidatableAvaloniaViewModelBase() { }

    /// <summary>
    /// <inheritdoc cref="IDirtyMonitoring.IsDirty"/>
    /// </summary>
    public bool IsDirty
    {
        get => _isDirty;
        set => this.RaiseAndSetIfChanged(ref _isDirty, value);
    }

    /// <summary>
    /// <inheritdoc cref="IDirtyMonitoring.Hash"/>
    /// </summary>
    public string? Hash
    {
        get => _hash;
        set => this.RaiseAndSetIfChanged(ref _hash, value);
    }

    /// <summary>
    /// Properties containing changes
    /// </summary>
    public IEnumerable<PropertyInfo>? ChangedProperties
    {
        get => _changedProperties;
        set => this.RaiseAndSetIfChanged(ref _changedProperties, value);
    }

    /// <summary>
    /// Fields containing changes
    /// </summary>
    public IEnumerable<FieldInfo>? ChangedFields
    {
        get => _changedFields;
        set => this.RaiseAndSetIfChanged(ref _changedFields, value);
    }

    /// <summary>
    /// Validate this instance
    /// </summary>
    public virtual void Validate()
    {
        IsDirtyValidator.Validate(this);
    }
    
    /// <summary>
    /// Validates this instance with full property tracking
    /// </summary>
    public virtual void StartValidateAndTrack()
    {
        IsDirtyValidator.Validate(this, true);
    }
    
    /// <summary>
    /// Validates this instance with full property tracking
    /// </summary>
    public virtual void GetChanged()
    {
        (ChangedProperties, ChangedFields) = IsDirtyValidator.ValidatePropertiesAndFields(this);
    }

    /// <summary>
    /// Stop tracking this instance
    /// </summary>
    public virtual void StopTracking()
    {
        IsDirtyValidator.StopTrackingObject(this);
    }
}

IsDirty Color Converter

/// <summary>
/// A binding helper for IsDirty UI Feedback
/// </summary>
public class IsDirtyColorConverter : IValueConverter
{
	/// <summary>
	/// The IsDirty=False color
	/// </summary>
	public SolidColorBrush FalseColor { get; set; } = new SolidColorBrush(Color.Parse("#B8FFB8"));

	/// <summary>
	/// The IsDirty=True color
	/// </summary>
	public SolidColorBrush TrueColor { get; set; } = new SolidColorBrush(Color.Parse("#FF8D8D"));
	
	/// <inheritdoc cref="IValueConverter.Convert"/>
	public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
	{
		if (value != null)
		{
			switch (value)
			{
				case true:
					return TrueColor;
				case false:
					return FalseColor;
			}
		}

		return FalseColor;
	}

	/// <inheritdoc cref="IValueConverter.ConvertBack"/>
	public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
	{
		return null;
	}
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.2.3 135 6/23/2024
1.2.2 133 6/23/2024 1.2.2 is deprecated because it has critical bugs.
1.2.1 326 12/23/2023
1.2.0 129 12/23/2023
1.1.4 201 6/18/2023
1.1.3 160 5/1/2023
1.1.2 231 3/4/2023
1.1.1 242 2/23/2023
1.1.0 234 2/18/2023