{"record":{"id":"94bf03dc071a841a","repo":"dotnet/wpf","slug":"sr-format-sr-propertypathsyntaxerror-detail","errorCode":null,"errorMessage":"SR.Format(SR.PropertyPathSyntaxError, detail)","messagePattern":"SR\\.Format\\(SR\\.PropertyPathSyntaxError, detail\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/PropertyPath.cs","lineNumber":375,"sourceCode":"        //------------------------------------------------------\n        //\n        //  Private methods\n        //\n        //------------------------------------------------------\n\n        // parse the path to figure out what kind of\n        // SourceValueInfo we're going to need\n        private void PrepareSourceValueInfo(ITypeDescriptorContext typeDescriptorContext)\n        {\n            PathParser parser = DataBindEngine.CurrentDataBindEngine.PathParser;\n            _arySVI = parser.Parse(Path);\n\n            if (_arySVI.Length == 0)\n            {\n                string detail = parser.Error;\n                if (detail == null)\n                    detail = Path;\n                throw new InvalidOperationException(SR.Format(SR.PropertyPathSyntaxError, detail));\n            }\n\n            ResolvePathParts(typeDescriptorContext);\n        }\n\n        // \"normalize\" the path - i.e. load the PathParameters with the early-bound\n        // accessors, and replace the corresponding parts of the path with\n        // parameter references\n        private void NormalizePath()\n        {\n            StringBuilder builder = new StringBuilder();\n            PathParameterCollection parameters = new PathParameterCollection();\n\n            for (int i=0; i<_arySVI.Length; ++i)\n            {\n                switch (_arySVI[i].drillIn)\n                {\n                    case DrillIn.Always:","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/PropertyPath.cs#L357-L393","documentation":"PropertyPath builds source-value info from its parsed path; if the parser produced no path steps (_arySVI.Length == 0), the path string itself is syntactically invalid. The exception surfaces the parser's error detail (or the raw Path) to indicate the syntax problem.","triggerScenarios":"Binding or storyboard targeting with a malformed PropertyPath string — e.g. empty path, unbalanced parentheses/brackets, bad indexer syntax, invalid leading characters — so the parser yields zero steps.","commonSituations":"Typo in binding Path like '()()' or '[', paths constructed programmatically with new PropertyPath(\"\"), localized/generated path strings corrupted, WPF property paths copied from other frameworks (different syntax).","solutions":["Fix the path string syntax (valid form: PropertyName.SubProp[Index].(AttachedType.Prop)).","Validate the path against the target object's actual property names.","Use non-empty path or Path='.' for self-reference.","Test the binding with a known-good simple path, then build up complexity."],"exampleFix":"// before\nbinding.Path = new PropertyPath(\"(Panel.ZIndex\"); // unbalanced paren\n// after\nbinding.Path = new PropertyPath(\"(Panel.ZIndex)\");","handlingStrategy":"validation","validationCode":"bool pathLooksValid(string p) => !string.IsNullOrWhiteSpace(p) &&\n    p.Count(c => c == '(') == p.Count(c => c == ')') &&\n    p.Count(c => c == '[') == p.Count(c => c == ']');","typeGuard":"bool HasSteps(PropertyPath pp) => pp != null && pp.PathParameters != null; // plus catch at bind time\nbool IsValidPathString(string p) => pathLooksValid(p);","tryCatchPattern":"try { binding.Path = new PropertyPath(pathString); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Syntax\"))\n{ Trace.WriteLine($\"Bad PropertyPath: {pathString}\"); }","preventionTips":["Keep property path strings in constants/resources with tests.","Validate balanced ()/[] in dynamically generated paths.","Verify property names exist on the source object.","Prefer typed paths or x:Bind-style compile-checked alternatives where available."],"tags":["wpf","binding","propertypath","syntax"],"backgroundTag":"invalid-argument-format","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"}