{"record":{"id":"ccbb4c50c4337d5b","repo":"dotnet/wpf","slug":"sr-animation-childmustbekeyframe-ccbb4c","errorCode":null,"errorMessage":"SR.Animation_ChildMustBeKeyFrame","messagePattern":"SR\\.Animation_ChildMustBeKeyFrame","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Point3DAnimationUsingKeyFrames.cs","lineNumber":227,"sourceCode":"            WritePostscript();\n        }\n\n        /// <summary>\n        /// Implemented to allow KeyFrames to be direct children\n        /// of KeyFrameAnimations in markup.\n        /// </summary>\n        [EditorBrowsable(EditorBrowsableState.Advanced)]\n        protected virtual void AddChild(object child)\n        {\n            Point3DKeyFrame keyFrame = child as Point3DKeyFrame;\n\n            if (keyFrame != null)\n            {\n                KeyFrames.Add(keyFrame);\n            }\n            else\n            {        \n                throw new ArgumentException(SR.Animation_ChildMustBeKeyFrame, nameof(child));\n            }\n        }\n\n        /// <summary>\n        /// Adds a text string as a child of this KeyFrameAnimation.\n        /// </summary>\n        /// <param name=\"childText\">\n        /// The text to add.\n        /// </param>\n        /// <remarks>\n        /// A KeyFrameAnimation does not accept text as a child, so this method will\n        /// raise an InvalididOperationException unless a derived class has\n        /// overridden the behavior to add text.\n        /// </remarks>\n        /// <exception cref=\"ArgumentNullException\">The childText parameter is\n        /// null.</exception>\n        void IAddChild.AddText(string childText)\n        {","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Point3DAnimationUsingKeyFrames.cs#L209-L245","documentation":"ArgumentException thrown by Point3DAnimationUsingKeyFrames.AddChild (the IAddChild path used for XAML markup children): the child object is not a Point3DKeyFrame, and key-frame animations only accept key frames of their specific type as direct children.","triggerScenarios":"Calling AddChild with null or a non-Point3DKeyFrame object, or XAML nesting an unsupported element inside <Point3DAnimationUsingKeyFrames>.","commonSituations":"Wrong key-frame type in XAML (e.g. DoubleKeyFrame), plain values as children, or code passing arbitrary objects to AddChild.","solutions":["Use Point3D key frames such as LinearPoint3DKeyFrame or SplinePoint3DKeyFrame as children","Type-check the child (is Point3DKeyFrame) before calling AddChild","Add frames via KeyFrames.Add in code"],"exampleFix":"// before\nanim.AddChild(new Point3D(1,2,3));\n// after\nanim.KeyFrames.Add(new LinearPoint3DKeyFrame(new Point3D(1,2,3), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1))));","handlingStrategy":"type-guard","validationCode":"if (child is Point3DKeyFrame kf) animation.KeyFrames.Add(kf);","typeGuard":"bool IsPoint3DKeyFrame(object c) => c is Point3DKeyFrame;","tryCatchPattern":"try { animation.AddChild(child); }\ncatch (ArgumentException ex) when (ex.ParamName == nameof(child)) { /* use a Point3DKeyFrame child instead */ }","preventionTips":["Only nest Point3D key frames in Point3DAnimationUsingKeyFrames","Wrap raw Point3D values in Linear/Discrete/Spline key frames","Prefer the typed KeyFrames.Add API in code"],"tags":["wpf","animation","xaml","argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}