{"record":{"id":"dbb492470056113d","repo":"dotnet/maui","slug":"path-cannot-be-an-empty-string","errorCode":null,"errorMessage":"path cannot be an empty string","messagePattern":"path cannot be an empty string","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/Binding.cs","lineNumber":46,"sourceCode":"\t\tpublic Binding()\n\t\t{\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Initializes a new instance of the <see cref=\"Binding\"/> class with the specified path, mode, converter, and source.\n\t\t/// </summary>\n\t\t/// <param name=\"path\">The property path to bind to.</param>\n\t\t/// <param name=\"mode\">The binding mode.</param>\n\t\t/// <param name=\"converter\">The value converter to use.</param>\n\t\t/// <param name=\"converterParameter\">The parameter to pass to the converter.</param>\n\t\t/// <param name=\"stringFormat\">The string format to apply to the bound value.</param>\n\t\t/// <param name=\"source\">The source object for the binding.</param>\n\t\tpublic Binding(string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null, object converterParameter = null, string stringFormat = null, object source = null)\n\t\t{\n\t\t\tif (path == null)\n\t\t\t\tthrow new ArgumentNullException(nameof(path));\n\t\t\tif (string.IsNullOrWhiteSpace(path))\n\t\t\t\tthrow new ArgumentException(\"path cannot be an empty string\", nameof(path));\n\n\t\t\tPath = path;\n\t\t\tConverter = converter;\n\t\t\tConverterParameter = converterParameter;\n\t\t\tMode = mode;\n\t\t\tStringFormat = stringFormat;\n\t\t\tSource = source;\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Gets or sets the converter used to convert values between the source and target.\n\t\t/// </summary>\n\t\tpublic IValueConverter Converter\n\t\t{\n\t\t\tget { return _converter; }\n\t\t\tset\n\t\t\t{\n\t\t\t\tThrowIfApplied();","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/Binding.cs#L28-L64","documentation":"ArgumentException from the Binding constructor when path is non-null but empty or whitespace. The constructor first rejects null path with ArgumentNullException, then this check rejects blank paths because a binding needs a real property path. Path is the primary identifier of the source member to bind.","triggerScenarios":"new Binding(\"\") or new Binding(\"   \"); building a Binding with a path variable that came back empty (e.g. nameof() on a private field in a context where it returned \"\"); constructing bindings from data that yielded an empty string.","commonSituations":"Dynamic binding construction from user/mapped data; refactor where the bound member was removed and nameof returned an unexpected token; copy-paste leaving the path blank.","solutions":["Supply a non-empty property path, e.g. nameof(MyViewModel.Title).","If the path is computed, validate !string.IsNullOrWhiteSpace(path) before constructing the Binding.","Use the Self binding source (BindingMode) or a relative source if you intentionally need no path."],"exampleFix":"// before\nvar b = new Binding(_pathField);\n\n// after\nif (string.IsNullOrWhiteSpace(_pathField))\n    throw new InvalidOperationException(\"Binding path must be set.\");\nvar b = new Binding(_pathField);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(path))\n    throw new ArgumentException(\"Binding path is required.\", nameof(path));\nvar binding = new Binding(path);","typeGuard":"static bool IsValidBindingPath(string path) =>\n    !string.IsNullOrWhiteSpace(path);","tryCatchPattern":null,"preventionTips":["Always derive paths from nameof() or constants, never from unchecked input.","Validate dynamic paths before constructing the Binding."],"tags":["maui","data-binding","argument-validation","nullable"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}