From d78840d7563155836b18a3a7fedb33b02f6d52da Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Wed, 11 Apr 2018 01:11:43 +0800 Subject: [PATCH] Minor fix. --- .../Animation/Keyframes/TransformKeyFrames.cs | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Avalonia.Visuals/Animation/Keyframes/TransformKeyFrames.cs b/src/Avalonia.Visuals/Animation/Keyframes/TransformKeyFrames.cs index 81455b5e50..df6107814b 100644 --- a/src/Avalonia.Visuals/Animation/Keyframes/TransformKeyFrames.cs +++ b/src/Avalonia.Visuals/Animation/Keyframes/TransformKeyFrames.cs @@ -22,37 +22,36 @@ namespace Avalonia.Animation.Keyframes { var ctrl = (Visual)control; - // Check if the AvaloniaProperty is Transform derived. - if (typeof(Transform).IsAssignableFrom(Property.OwnerType)) + // Check if the Target Property is Transform derived. + if (typeof(Transform).IsAssignableFrom(Property.OwnerType) && ctrl.RenderTransform != null) { var renderTransformType = ctrl.RenderTransform.GetType(); - + if (childKeyFrames == null) { InitializeInternalDoubleKeyFrames(); } - if(ctrl.RenderTransform != null) + // It's only 1 transform object so let's target that. + if (renderTransformType == Property.OwnerType) { - // It's only 1 transform object so let's target that. - if (renderTransformType == Property.OwnerType) - { - return childKeyFrames.Apply(animation, ctrl.RenderTransform, obsMatch); - } - else if (renderTransformType == typeof(TransformGroup)) + return childKeyFrames.Apply(animation, ctrl.RenderTransform, obsMatch); + } + // Try if the control's RenderTransform is a TransformGroup and find + // the target there. + else if (renderTransformType == typeof(TransformGroup)) + { + foreach (Transform transform in ((TransformGroup)ctrl.RenderTransform).Children) { - foreach (Transform transform in ((TransformGroup)ctrl.RenderTransform).Children) + if (transform.GetType() == Property.OwnerType) { - if (transform.GetType() == Property.OwnerType) - { - return childKeyFrames.Apply(animation, transform, obsMatch); - } + return childKeyFrames.Apply(animation, transform, obsMatch); } } - - //throw new InvalidOperationException($"TransformKeyFrame hasn't found an appropriate Transform object with type {Property.OwnerType} in target {control}."); } + //throw new InvalidOperationException($"TransformKeyFrame hasn't found an appropriate Transform object with type {Property.OwnerType} in target {control}."); + return null; }