AvaloniaUI/Avalonia · error · InvalidOperationException
{item.DebugDisplay} must have a value of type {typeof(Transf
Error message
{item.DebugDisplay} must have a value of type {typeof(TransformOperations)}. What it means
Thrown by TransformOperationsAnimator's list validator (IAvaloniaListItemValidator<AnimatorKeyFrame>.Validate) when an added AnimatorKeyFrame's Value is not a TransformOperations instance. This animator exclusively interpolates TransformOperations, so any other value type in a key frame is rejected at insertion time.
Source
Thrown at src/Avalonia.Base/Animation/Animators/TransformOperationsAnimator.cs:32
public override TransformOperations Interpolate(double progress, TransformOperations oldValue, TransformOperations newValue)
{
var oldTransform = EnsureOperations(oldValue);
var newTransform = EnsureOperations(newValue);
return TransformOperations.Interpolate(oldTransform, newTransform, progress);
}
internal static TransformOperations EnsureOperations(ITransform value)
{
return value as TransformOperations ?? TransformOperations.Identity;
}
void IAvaloniaListItemValidator<AnimatorKeyFrame>.Validate(AnimatorKeyFrame item)
{
if (item.Value is not TransformOperations)
{
throw new InvalidOperationException($"{item.DebugDisplay} must have a value of type {typeof(TransformOperations)}.");
}
}
}
}
View on GitHub (pinned to 11c5427268)
Solutions
- Set each key frame's Value to a TransformOperations instance.
- Build TransformOperations via TransformOperations.Parse from a CSS-style transform string.
- Use TransformAnimator instead if you need non-TransformOperations transform types.
Example fix
// before
kf.Value = "translate(10px)"; // string, not TransformOperations
// after
kf.Value = TransformOperations.Parse("translate(10px)"); Defensive patterns
Strategy: type-guard
Validate before calling
foreach (var kf in animator)
if (kf.Value is not TransformOperations)
throw new InvalidOperationException($"KeyFrame value must be TransformOperations, got {kf.Value?.GetType()}."); Type guard
static bool ValueIsTransformOperations(AnimatorKeyFrame kf) => kf.Value is TransformOperations;
Prevention
- Always set TransformOperationsAnimator key-frame Values to TransformOperations instances.
- Use TransformOperations.Parse for CSS-style transform strings.
- Pick TransformAnimator over TransformOperationsAnimator when the value type differs.
When it happens
Trigger: Adding an AnimatorKeyFrame whose Value is any type other than TransformOperations to a TransformOperationsAnimator's key frame collection (e.g. setting Value to a string, double, or a different ITransform).
Common situations: XAML key frame using a non-transform value or a raw Transform string instead of a TransformOperations; programmatic key frame with the wrong value type; confusing TransformAnimator with TransformOperationsAnimator.
Related errors
- KeyFrame value can't be null.
- KeyFrame value doesnt match property type.
- Animator has no property specified.
- You can only set either {nameof(KeyTime)} or {nameof(Cue)}.
- No Setter property assigned.
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/69e9bdc3a2ec8933.
Report an issue: GitHub.