Skip to content

Add Converter to reduce a numeric value in a XamlBinding #264

@AndreasReitberger

Description

@AndreasReitberger
public sealed class NumericCalculationConverter : IValueConverter
{
    public double Adjustment { get; set; } = 0;

    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is double numVal)
        {
            return numVal + Adjustment;
        }
        return value;
    }

    public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is double numVal)
        {
            return numVal - Adjustment;
        }
        return value;
    }
}

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions