diff --git a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs index 8f0b710f63..d60542a6b4 100644 --- a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs +++ b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs @@ -51,17 +51,14 @@ namespace Avalonia.Animation.Animators if (_colorAnimator == null) InitializeColorAnimator(); - SolidColorBrush finalTarget; - // If it's ISCB, change it back to SCB. - if (targetVal.GetType() == typeof(ImmutableSolidColorBrush)) + if (targetVal is ImmutableSolidColorBrush immutableSolidColorBrush) { - var col = (ImmutableSolidColorBrush)targetVal; - targetVal = new SolidColorBrush(col.Color); + targetVal = new SolidColorBrush(immutableSolidColorBrush.Color); control.SetValue(Property, targetVal); } - finalTarget = targetVal as SolidColorBrush; + var finalTarget = targetVal as SolidColorBrush; return _colorAnimator.Apply(animation, finalTarget, clock ?? control.Clock, match, onComplete); }