dotnet/wpf · error · ArgumentException
SR.Animation_AnimationTimelineTypeMismatch
Error message
SR.Animation_AnimationTimelineTypeMismatch
What it means
Thrown by IAnimatable.ApplyAnimationClock when the clock's Timeline is not a valid animation for the target property — AnimationStorage.IsAnimationValid fails because the AnimationTimeline's output type does not match the DependencyProperty's type.
Solutions
- Use an AnimationTimeline whose target value type matches dp.PropertyType (e.g. ColorAnimation for Color properties).
- Check clock.Timeline.GetType() and dp.PropertyType at the call site to confirm compatibility.
- Create a new clock for the property instead of reusing one from a differently-typed animation.
Example fix
// before brush.ApplyAnimationClock(SolidColorBrush.ColorProperty, doubleAnimClock); // after brush.ApplyAnimationClock(SolidColorBrush.ColorProperty, new ColorAnimation(Colors.Red, TimeSpan.FromSeconds(1)).CreateClock());
Defensive patterns
Strategy: validation
Validate before calling
if (clock != null && !dp.PropertyType.IsInstanceOfType(((AnimationTimeline)clock.Timeline).GetCurrentValue(default(object), default(object)))) throw new InvalidOperationException("Timeline type mismatch"); Type guard
static bool TimelineMatches(AnimationClock clock, DependencyProperty dp) => clock?.Timeline is AnimationTimeline tl && dp.PropertyType.IsAssignableFrom(tl.TargetPropertyType);
Try / catch
try { target.ApplyAnimationClock(dp, clock, handoff); } catch (ArgumentException ex) when (ex.ParamName == nameof(clock)) { log.Warn($"Clock timeline {clock.Timeline.GetType()} incompatible with {dp.PropertyType}"); } Prevention
- Match animation class to property type: Double->DoubleAnimation, Color->ColorAnimation, Point->PointAnimation.
- Use Storyboards in XAML where the compiler/linter checks target property compatibility.
- Don't reuse clocks across properties of different types.
When it happens
Trigger: Calling ApplyAnimationClock(dp, clock, handoffBehavior) where clock.Timeline's typed value (e.g. DoubleAnimation producing double) does not match dp.PropertyType (e.g. Color property).
Common situations: Using a DoubleAnimation clock on a Color property like SolidColorBrush.Color; passing a clock created for another property type; reusing a clock across differently-typed properties.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Animation_AnimationTimelineTypeMismatch
- SR.Animation_ChildMustBeKeyFrame
- SR.Animation_ChildMustBeKeyFrame
- SR.Animation_ChildMustBeKeyFrame
- SR.Animation_ChildMustBeKeyFrame
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/a884538f005a6780.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/generators/IAnimatableHelper.cs:84
/// Determines how the new AnimationClock will transition from or
/// affect any current animations on the property.
/// </param>
public void ApplyAnimationClock(
DependencyProperty dp,
AnimationClock clock,
HandoffBehavior handoffBehavior)
{
ArgumentNullException.ThrowIfNull(dp);
if (!AnimationStorage.IsPropertyAnimatable(this, dp))
{
throw new ArgumentException(SR.Format(SR.Animation_DependencyPropertyIsNotAnimatable, dp.Name, this.GetType()), nameof(dp));
}
if (clock != null
&& !AnimationStorage.IsAnimationValid(dp, clock.Timeline))
{
throw new ArgumentException(SR.Format(SR.Animation_AnimationTimelineTypeMismatch, clock.Timeline.GetType(), dp.Name, dp.PropertyType), nameof(clock));
}
if (!HandoffBehaviorEnum.IsDefined(handoffBehavior))
{
throw new ArgumentException(SR.Animation_UnrecognizedHandoffBehavior);
}
if (IsSealed)
{
throw new InvalidOperationException(SR.Format(SR.IAnimatable_CantAnimateSealedDO, dp, this.GetType()));
}
AnimationStorage.ApplyAnimationClock(this, dp, clock, handoffBehavior);
}
/// <summary>
/// Starts an animation for a DependencyProperty. The animation will
/// begin when the next frame is rendered.View on GitHub (pinned to 81131a70a4)