{"record":{"id":"cc6be9853ac49ffb","repo":"dotnet/wpf","slug":"sr-format-sr-parentlesspropertyelement-propname-scopedname","errorCode":null,"errorMessage":"SR.Format(SR.ParentlessPropertyElement, propName.ScopedName)","messagePattern":"SR\\.Format\\(SR\\.ParentlessPropertyElement, propName\\.ScopedName\\)","errorType":"exception","errorClass":"XamlInternalException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/XamlContext.cs","lineNumber":79,"sourceCode":"            return IsVisible(member, null) ? member : null;\n        }\n\n        /// <summary>\n        /// Resolves a property of the form 'Foo.Bar' or 'a:Foo.Bar', in\n        /// in the context of a parent tag.  The parent tagType may or may not\n        /// be covariant with the ownerType.  In the case of dotted attribute\n        /// syntax, the namespace my be passed in.\n        /// </summary>\n        /// <param name=\"tagType\">The xamlType of the enclosing Tag</param>\n        /// <param name=\"tagNamespace\">The namespace of the enclosing Tag</param>\n        /// <param name=\"propName\">The dotted name of the property</param>\n        /// <param name=\"tagIsRoot\">Whether the tag is the root of the document</param>\n        /// <returns></returns>\n        public XamlMember GetDottedProperty(XamlType tagType, string tagNamespace, XamlPropertyName propName, bool tagIsRoot)\n        {\n            if (tagType is null)\n            {\n                throw new XamlInternalException(SR.Format(SR.ParentlessPropertyElement, propName.ScopedName));\n            }\n\n            XamlMember property = null;\n            XamlType ownerType = null;\n            string ns = ResolveXamlNameNS(propName);\n            if (ns is null)\n            {\n                throw new XamlParseException(SR.Format(SR.PrefixNotFound, propName.Prefix));\n            }\n\n            XamlType rootTagType = tagIsRoot ? tagType : null;\n\n            // If we have <foo x:TA=\"\" foo.bar=\"\"/> we want foo in foo.bar to match the tag\n            // type since there is no way to specify generic syntax in dotted property notation\n            // If that fails, then we fall back to the non-generic case below.\n            bool ownerTypeMatchesGenericTagType = false;\n            if (tagType.IsGeneric)\n            {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/XamlContext.cs#L61-L97","documentation":"GetDottedProperty resolves dotted (property-element) names like <foo.bar/>. If the enclosing tag type cannot be determined (tagType is null), it throws XamlInternalException with ParentlessPropertyElement carrying the scoped property name — the parser hit a property element with no owning type in scope.","triggerScenarios":"XAML parsing reaches a dotted property element (e.g. <Grid.Row> syntax internally) when no current object type is available, typically with malformed markup such as a property element appearing outside/before its owner element.","commonSituations":"Hand-edited XAML with a property element at the document root or before the opening object tag; tooling-generated XAML with mismatched nesting; programmatic parsing of fragment XAML lacking a root object.","solutions":["Fix the markup so the property element is nested inside its owning object element.","Ensure the document has a valid root object element before any property elements.","If parsing fragments, wrap them in a valid parent element first.","Catch XamlParseException/XamlInternalException during parse and surface the file/line for author correction."],"exampleFix":"// before (malformed XAML)\n<Window><Window.Title>...</Window.Title></Window> <!-- misplaced: root wrapper missing -->\n// after\n<Window xmlns=\"...\"><Window.Title>...</Window.Title></Window> <!-- property element inside owner -->","handlingStrategy":"validation","validationCode":"// pre-parse check: every dotted property element must be inside an object element\nif (xml.Descendants().Any(e => e.Name.LocalName.Contains('.') && e.Parent == null))\n    throw new XamlParseException(\"Property element at document root has no owner\");","typeGuard":"bool HasOwnerType(XamlType tagType) => tagType != null;","tryCatchPattern":"try { parser.Load(xaml); }\ncatch (XamlInternalException ex) { // property element without owner type — fix markup nesting\n  throw new FormatException(\"Malformed XAML: \" + ex.Message, ex); }","preventionTips":["Validate XAML nesting with an XML parser before loading","Never place property elements at the document root","When parsing fragments, wrap them in a valid parent"],"tags":["wpf","system-xaml","xaml-parse","malformed-markup","internal-error"],"backgroundTag":"schema-validation-failed","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"}