AvaloniaUI/Avalonia · error · ArgumentException

Invalid value for Property '{propertyName}': '{value}' ({typ

Error message

Invalid value for Property '{propertyName}': '{value}' ({type})

What it means

Error "Invalid value for Property '{propertyName}': '{value}' ({type})" thrown in AvaloniaUI/Avalonia.

Source

Thrown at src/Avalonia.Base/StyledPropertyNonGenericHelper.cs:19

using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace Avalonia;

/// <summary>
/// Contains methods for <see cref="StyledProperty{TValue}"/> that aren't using generic arguments.
/// Separated to avoid unnecessary generic instantiations.
/// </summary>
internal static class StyledPropertyNonGenericHelper
{
    [DoesNotReturn]
    [MethodImpl(MethodImplOptions.NoInlining)]
    public static void ThrowInvalidValue(string propertyName, object? value, string paramName)
    {
        var type = value?.GetType().FullName ?? "(null)";

        throw new ArgumentException(
            $"Invalid value for Property '{propertyName}': '{value}' ({type})",
            paramName);
    }

    public static void ThrowInvalidDefaultValue(string propertyName, object? defaultValue, string paramName)
    {
        throw new ArgumentException(
            $"'{defaultValue}' is not a valid default value for '{propertyName}'.",
            paramName);
    }
}

View on GitHub (pinned to 11c5427268)

Solutions

  1. Provide a value whose type is assignable to the property's registered value type.
  2. Cast or convert the value (e.g. via a TypeConverter or binding converter) before setting the property.

When it happens

Trigger: Raised when a non-generic styled property is assigned a value that fails conversion or validation for the property type. Defend by validating values against the property type before setting and using the strongly-typed SetValue overload where possible.

Common situations: See trigger scenarios.


AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13). Data as JSON: /api/errors/6fc9cf84f14cffd3. Report an issue: GitHub.