{"record":{"id":"fe50abe9cb386e97","repo":"dotnet/maui","slug":"targetproperty-fe50ab","errorCode":null,"errorMessage":"targetProperty","messagePattern":"targetProperty","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/BindableObjectExtensions.cs","lineNumber":67,"sourceCode":"\t\t\t}\n\t\t}\n\n\t\t/// <summary>Creates and applies a binding to a property.</summary>\n\t\t/// <param name=\"self\">The <see cref=\"Microsoft.Maui.Controls.BindableObject\"/>.</param>\n\t\t/// <param name=\"targetProperty\">The BindableProperty on which to set a binding.</param>\n\t\t/// <param name=\"path\">A <see cref=\"System.String\"/> indicating the property path to bind to.</param>\n\t\t/// <param name=\"mode\">The <see cref=\"Microsoft.Maui.Controls.BindingMode\"/> for the binding. This parameter is optional. Default is <see cref=\"Microsoft.Maui.Controls.BindingMode.Default\"/>.</param>\n\t\t/// <param name=\"converter\">An <see cref=\"Microsoft.Maui.Controls.IValueConverter\"/> for the binding. This parameter is optional. Default is <see langword=\"null\"/>.</param>\n\t\t/// <param name=\"stringFormat\">A string used as stringFormat for the binding. This parameter is optional. Default is <see langword=\"null\"/>.</param>\n\t\t/// <remarks>The following example shows how to use the extension method to set a binding.</remarks>\n\t\t[RequiresUnreferencedCode(TrimmerConstants.StringPathBindingWarning, Url = TrimmerConstants.ExpressionBasedBindingsDocsUrl)]\n\t\tpublic static void SetBinding(this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null,\n\t\t\t\t\t\t\t\t\t  string stringFormat = null)\n\t\t{\n\t\t\tif (self == null)\n\t\t\t\tthrow new ArgumentNullException(nameof(self));\n\t\t\tif (targetProperty == null)\n\t\t\t\tthrow new ArgumentNullException(nameof(targetProperty));\n\n\t\t\tvar binding = new Binding(path, mode, converter, stringFormat: stringFormat);\n\t\t\tself.SetBinding(targetProperty, binding);\n\t\t}\n\n#nullable enable\n\t\t/// <summary>\n\t\t/// Creates a binding between a property on the source object and a property on the target object.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t///   <para>The following example illustrates the setting of a binding using the extension method.</para>\n\t\t///   <example>\n\t\t///     <code lang=\"csharp lang-csharp\"><![CDATA[\n\t\t///      public class PersonViewModel\n\t\t///      {\n\t\t///          public string Name { get; set; }\n\t\t///          public Address? Address { get; set; }\n\t\t///          // ...","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/BindableObjectExtensions.cs#L49-L85","documentation":"Thrown by BindableObjectExtensions.SetBinding(this BindableObject, BindableProperty, string, ...) when targetProperty is null. This string-path extension builds a Binding and forwards to instance.SetBinding; the null guard prevents constructing a binding against an undefined target and matches the guard in the underlying SetBinding.","triggerScenarios":"Calling the string-path SetBinding with a null BindableProperty field; referencing a property field that was never initialized or was renamed; a property lookup helper returning null.","commonSituations":"Refactor that renamed a BindableProperty field; binding to a property declared on a different type; generic helpers resolving properties by name.","solutions":["Pass the correct static BindableProperty field for the target type.","Null-check targetProperty before calling when it is resolved dynamically.","Verify the BindableProperty field exists on the object type you are extending."],"exampleFix":"// before\nview.SetBinding(maybeNullProp, \"Foo\");\n// after\nif (maybeNullProp is not null)\n    view.SetBinding(maybeNullProp, \"Foo\");","handlingStrategy":"validation","validationCode":"if (targetProperty is null) throw new InvalidOperationException(\"targetProperty not resolved\");\nself.SetBinding(targetProperty, path);","typeGuard":"static bool CanBindStringPath(Microsoft.Maui.Controls.BindableObject o, Microsoft.Maui.Controls.BindableProperty p)\n    => o is not null && p is not null;","tryCatchPattern":null,"preventionTips":["Reference the BindableProperty field with nameof to catch renames at compile time.","Confirm the field is declared on the type you are binding on."],"tags":["maui","binding","argument-null","bindableproperty","extension-method"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}