{"record":{"id":"dede1790bff3cdec","repo":"dotnet/wpf","slug":"sr-timing-childmustbetimeline","errorCode":null,"errorMessage":"SR.Timing_ChildMustBeTimeline","messagePattern":"SR\\.Timing_ChildMustBeTimeline","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/TimelineGroup.cs","lineNumber":145,"sourceCode":"        /// class implementation only if they determine that it's the right\n        /// course of action.  The derived class can rely on Timeline's\n        /// implementation of IAddChild.AddChild or implement their own\n        /// following the Freezable pattern since that would be a public\n        /// method.\n        /// </remarks>\n        /// <param name=\"child\">An object representing the child that\n        /// should be added.  If this is a Timeline it will be added to the\n        /// Children collection; otherwise an exception will be thrown.</param>\n        /// <exception cref=\"ArgumentException\">The child parameter is not a\n        /// Timeline.</exception>\n        [EditorBrowsable(EditorBrowsableState.Advanced)]\n        protected virtual void AddChild(object child)\n        {\n            Timeline timelineChild = child as Timeline;\n\n            if (timelineChild == null)\n            {\n                throw new ArgumentException(SR.Timing_ChildMustBeTimeline, nameof(child));\n            }\n            else\n            {\n                Children.Add(timelineChild);\n            }\n        }\n\n        /// <summary>\n        /// Adds a text string as a child of this Timeline.\n        /// </summary>\n        /// <param name=\"childText\">\n        /// The text to add.\n        /// </param>\n        /// <remarks>\n        /// A Timeline 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>","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/TimelineGroup.cs#L127-L163","documentation":"Thrown by TimelineGroup.AddChild (the IAddChild implementation for timeline parents like ParallelTimeline and Storyboard) when the child object added in XAML or code is not a Timeline. Only Timeline-derived children may be nested inside a timeline group.","triggerScenarios":"Calling AddChild (directly or via XAML object element under a Storyboard/ParallelTimeline) with an object that is not a Timeline, e.g. a string, a DoubleAnimation's keyframes misplaced, or a non-timeline element nested in a storyboard.","commonSituations":"XAML typos where a non-Timeline element is placed inside <Storyboard> or <ParallelTimeline> (e.g. <Setter>, a brush, or a typo'd tag that parses to the wrong type); programmatic AddChild calls with the wrong object.","solutions":["Ensure the child is a Timeline-derived type (e.g. DoubleAnimation, DoubleAnimationUsingKeyFrames, ParallelTimeline)","Fix XAML nesting so only animation/timeline elements are direct children of Storyboard/ParallelTimeline; wrap values in the correct animation element","Cast or type-check the child before calling AddChild in code"],"exampleFix":"// before\nstoryboard.AddChild(someSetter);\n// after\nstoryboard.AddChild(new DoubleAnimation(from, to, duration));","handlingStrategy":"validation","validationCode":"if (child is Timeline timelineChild) storyboard.AddChild(timelineChild);","typeGuard":"bool isTimelineChild(object c) => c is Timeline;","tryCatchPattern":null,"preventionTips":["Only nest Timeline-derived elements inside Storyboard/ParallelTimeline in XAML","Type-check children before calling AddChild programmatically","Validate storyboard XAML with a XAML schema/designer"],"tags":["wpf","animation","xaml","argument"],"backgroundTag":"type-mismatch","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}