{"record":{"id":"3154f592882b2faa","repo":"dotnet/wpf","slug":"sr-format-sr-unexpectedparametertype-value-gettype-typeof-3154f5","errorCode":null,"errorMessage":"SR.Format(SR.UnexpectedParameterType, value.GetType(), typeof(TableRowStructure))","messagePattern":"SR\\.Format\\(SR\\.UnexpectedParameterType, value\\.GetType\\(\\), typeof\\(TableRowStructure\\)\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/DocumentStructures/SemanticBasicElement.cs","lineNumber":338,"sourceCode":"        public TableRowGroupStructure()\n        {\n            _elementType = FixedElement.ElementType.TableRowGroup;\n        }\n\n        public void Add(TableRowStructure tableRow)\n        {\n            ArgumentNullException.ThrowIfNull(tableRow);\n            ((IAddChild) this).AddChild(tableRow);\n        }\n        \n        void IAddChild.AddChild(object value)\n        {\n            if (value is TableRowStructure)\n            {\n                _elementList.Add((TableRowStructure)value);\n                return;\n            }\n            throw new ArgumentException(SR.Format(SR.UnexpectedParameterType, value.GetType(), typeof(TableRowStructure)), nameof(value));\n        }\n\n        void IAddChild.AddText(string text) { }\n\n        \n        IEnumerator<TableRowStructure> IEnumerable<TableRowStructure>.GetEnumerator()\n        {\n            throw new NotSupportedException();\n        }\n\n        IEnumerator IEnumerable.GetEnumerator()\n        {\n            return ((IEnumerable<TableRowStructure>)this).GetEnumerator();\n        }\n    }\n\n    /// <summary>\n    ///","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/DocumentStructures/SemanticBasicElement.cs#L320-L356","documentation":"This ArgumentException is thrown by TableRowStructure.AddChild when the child passed is not a TableRowStructure. A row structure only accepts cell structures as children per the XPS document structure schema.","triggerScenarios":"Calling AddChild on TableRowStructure with anything other than TableCellStructure, e.g. adding a Run, ParagraphStructure, or raw text element.","commonSituations":"Mistakenly adding UI or flow content directly into a row when building XPS documents in code or XAML.","solutions":["Wrap the content in a TableCellStructure and add that instead","Follow the hierarchy: TableRowStructure only contains TableCellStructure; put ParagraphStructure etc. inside cells","Verify the element type in the exception message","Type-check with 'value is TableCellStructure' before calling"],"exampleFix":"// before\nrow.AddChild(new ParagraphStructure());\n// after\nvar cell = new TableCellStructure();\ncell.Blocks.Add(new ParagraphStructure());\nrow.AddChild(cell);","handlingStrategy":"type-guard","validationCode":"if (value is not TableRowStructure) throw new ArgumentException(\"TableRowStructure.AddChild only accepts TableRowStructure\");","typeGuard":"bool IsRow(object o) => o is TableRowStructure;","tryCatchPattern":"try { rowAddChild(value); } catch (ArgumentException ex) { /* handle wrong-child-type */ }","preventionTips":["Add rows only at the row-group level","Wrap cell content in TableCellStructure","Verify XAML nesting of table structure elements"],"tags":["wpf","argumentexception","xps-table-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-21T21:30:21.729Z"}