{"record":{"id":"0bca10677576a713","repo":"dotnet/wpf","slug":"sr-format-sr-documentstructureunexpectedparametertype6-value","errorCode":null,"errorMessage":"SR.Format(SR.DocumentStructureUnexpectedParameterType6, value.GetType(), typeof(SectionStructure), typeof(ParagraphStructure), typeof(FigureStructure), typeof(ListStructure), typeof(TableStructure), typeof(StoryBreak))","messagePattern":"SR\\.Format\\(SR\\.DocumentStructureUnexpectedParameterType6, value\\.GetType\\(\\), typeof\\(SectionStructure\\), typeof\\(ParagraphStructure\\), typeof\\(FigureStructure\\), typeof\\(ListStructure\\), typeof\\(TableStructure\\), typeof\\(StoryBreak\\)\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/DocumentStructures/StoryFragments.cs","lineNumber":106,"sourceCode":"            ArgumentNullException.ThrowIfNull(element);\n            ((IAddChild) this).AddChild(element);\n        }\n        \n        void IAddChild.AddChild(object value)\n        {\n            //\n            // Only the following type are accepted. \n            // Section|Paragraph|Inline(Bold|Italic|Underline)|Floater|Figure|List\n            // |Table|StoryBreak\n            //\n            if (value is SectionStructure || value is ParagraphStructure || value is FigureStructure \n                || value is ListStructure || value is TableStructure || value is StoryBreak)\n            {\n                _elementList.Add( (BlockElement) value);\n                return;\n            }\n\n            throw new ArgumentException(SR.Format(SR.DocumentStructureUnexpectedParameterType6, value.GetType(),\n                typeof(SectionStructure), typeof(ParagraphStructure), typeof(FigureStructure), typeof(ListStructure), typeof(TableStructure), typeof(StoryBreak)),\n                nameof(value));\n        }\n        void IAddChild.AddText(string text) { }\n\n        IEnumerator<BlockElement> IEnumerable<BlockElement>.GetEnumerator()\n        {\n            throw new NotSupportedException();\n        }\n\n        IEnumerator IEnumerable.GetEnumerator()\n        {\n            return ((IEnumerable<BlockElement>)this).GetEnumerator();\n        }\n\n        /// <summary>\n        /// The element name\n        /// </summary>","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/DocumentStructures/StoryFragments.cs#L88-L124","documentation":"This ArgumentException is thrown by StoryFragment.AddChild when the child is not one of the six accepted block types: SectionStructure, ParagraphStructure, FigureStructure, ListStructure, TableStructure, or StoryBreak. StoryFragment enforces the XPS story structure schema at its content level.","triggerScenarios":"Calling AddChild on a StoryFragment with any other object — e.g. a PageContent, a TableRowStructure, or a plain UIElement.","commonSituations":"Mixing FixedPage content elements into StoryFragment content; hand-written XPS story markup with a wrong nested element.","solutions":["Use only the six accepted types as StoryFragment children","Move non-story elements (like PageContent) to FixedDocument instead","Inspect value.GetType() in the message to identify the bad object","Guard the call with an 'is' check against the accepted types"],"exampleFix":"// before\nfragment.AddChild(new PageContent());\n// after\nfixedDocument.Pages.Add(new PageContent()); // page content goes in the document, not the story","handlingStrategy":"type-guard","validationCode":"if (!(value is SectionStructure || value is ParagraphStructure || value is FigureStructure || value is ListStructure || value is TableStructure || value is StoryBreak)) throw new ArgumentException($\"{value.GetType()} not a valid StoryFragment child\");","typeGuard":"bool IsStoryBlock(object o) => o is SectionStructure || o is ParagraphStructure || o is FigureStructure || o is ListStructure || o is TableStructure || o is StoryBreak;","tryCatchPattern":"try { fragment.AddChild(value); } catch (ArgumentException ex) { /* redirect non-story types to their own containers */ }","preventionTips":["Memorize the six accepted StoryFragment child types","Never mix FixedPage content into story fragments","Use BlockElements typed collection where available"],"tags":["wpf","argumentexception","xps-story-structure","type-mismatch"],"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"}