{"record":{"id":"30af3b577d3492c7","repo":"dotnet/maui","slug":"xc0040","errorCode":"XC0040","errorMessage":"Cannot convert value \"{0}\" to \"{1}\".","messagePattern":"Cannot convert value \"(.+?)\" to \"(.+?)\"\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/CompiledConverters/BindablePropertyConverter.cs","lineNumber":61,"sourceCode":"\t\t\t\t\telse if (parent.XmlType.IsOfAnyType(nameof(VisualState)))\n\t\t\t\t\t{\n\t\t\t\t\t\ttypeName = FindTypeNameForVisualState(parent, node, context);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (node.Parent is ElementNode { XmlType: XmlType xt1 } && xt1.IsOfAnyType(nameof(Trigger)))\n\t\t\t\t{\n\t\t\t\t\ttypeName = GetTargetTypeName(node.Parent);\n\t\t\t\t}\n\t\t\t\tpropertyName = parts[0];\n\t\t\t}\n\t\t\telse if (parts.Length == 2)\n\t\t\t{\n\t\t\t\tvar targetType = parts[0];\n\t\t\t\ttypeName = TypeArgumentsParser.ParseSingle(targetType, node.NamespaceResolver, (IXmlLineInfo)node);\n\t\t\t\tpropertyName = parts[1];\n\t\t\t}\n\t\t\telse\n\t\t\t\tthrow new BuildException(Conversion, node, null, value, typeof(BindableProperty));\n\n\t\t\tif (typeName == null || propertyName == null)\n\t\t\t\tthrow new BuildException(Conversion, node, null, value, typeof(BindableProperty));\n\n\t\t\tvar typeRef = typeName.GetTypeReference(context.Cache, module, node);\n\t\t\tif (typeRef == null)\n\t\t\t\tthrow new BuildException(TypeResolution, node, null, typeName);\n\n\t\t\tbpRef = GetBindablePropertyFieldReference(context.Cache, typeRef, propertyName, module);\n\t\t\tif (bpRef == null)\n\t\t\t\tthrow new BuildException(PropertyResolution, node, null, propertyName, typeRef.Name);\n\t\t\treturn bpRef;\n\n\t\t\tstatic XmlType GetTargetTypeName(INode node)\n\t\t\t{\n\t\t\t\tvar targetType = ((node as ElementNode).Properties[new XmlName(\"\", \"TargetType\")] as ValueNode)?.Value as string;\n\t\t\t\treturn TypeArgumentsParser.ParseSingle(targetType, node.NamespaceResolver, (IXmlLineInfo)node);\n\t\t\t}","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CompiledConverters/BindablePropertyConverter.cs#L43-L79","documentation":"XamlC error XC0040 from BindablePropertyConverter. The converter splits the XAML value on '.' and accepts exactly 1 segment (property name, type inferred from context) or 2 segments (Type.Property). More than two dot-separated segments cannot be interpreted, so it throws a conversion (XC0040) error.","triggerScenarios":"A value with three or more dot-segments is used where a BindableProperty is expected — e.g. a full namespace like 'MyLib.Controls.MyView.SomeProperty' or 'Foo.Bar.Baz' in a Setter.Property.","commonSituations":"Typing a fully-qualified namespace instead of using an xmlns prefix; referencing a nested type through multiple namespace dots; mis-pasting a type path.","solutions":["Declare an xmlns prefix and use exactly Type.Property (two segments), e.g. local:MyView.SpacingProperty.","If only the property name is needed, place the setter inside a Style/Trigger/VisualState that has a TargetType so the type is inferred (single segment)."],"exampleFix":"<!-- before -->\n<Setter Property=\"MyLib.Controls.MyView.SpacingProperty\" Value=\"10\" />\n\n<!-- after -->\nxmlns:local=\"clr-namespace:MyLib.Controls\"\n<Setter Property=\"local:MyView.SpacingProperty\" Value=\"10\" />","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use an xmlns prefix and limit BindableProperty values to one or two dot-segments.","Never paste a fully-qualified namespace into a BindableProperty value; declare an xmlns instead.","Place context-dependent single-name properties inside a Style/Trigger/VisualState with a TargetType."],"tags":["xaml","xamlc","bindableproperty","compilation"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}