{"record":{"id":"db03143f781f3536","repo":"dotnet/wpf","slug":"sr-propertynotbindable-formatted-with-dp-name","errorCode":null,"errorMessage":"SR.PropertyNotBindable (formatted with dp.Name)","messagePattern":"SR\\.PropertyNotBindable \\(formatted with dp\\.Name\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/MultiBindingExpression.cs","lineNumber":159,"sourceCode":"\n    internal override bool IsParentBindingUpdateTriggerDefault\n    {\n        get { return (ParentMultiBinding.UpdateSourceTrigger == UpdateSourceTrigger.Default); }\n    }\n\n    //------------------------------------------------------\n    //\n    //  Internal Methods\n    //\n    //------------------------------------------------------\n\n    // Create a new BindingExpression from the given Binding description\n    internal static MultiBindingExpression CreateBindingExpression(DependencyObject d, DependencyProperty dp, MultiBinding binding, BindingExpressionBase owner)\n    {\n        FrameworkPropertyMetadata fwMetaData = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata;\n\n        if ((fwMetaData != null && !fwMetaData.IsDataBindingAllowed) || dp.ReadOnly)\n            throw new ArgumentException(SR.Format(SR.PropertyNotBindable, dp.Name), nameof(dp));\n\n        // create the BindingExpression\n        MultiBindingExpression bindExpr = new MultiBindingExpression(binding, owner);\n\n        bindExpr.ResolvePropertyDefaultSettings(binding.Mode, binding.UpdateSourceTrigger, fwMetaData);\n\n        return bindExpr;\n    }\n\n        // Attach to things that may require tree context (parent, root, etc.)\n        private void AttachToContext(bool lastChance)\n    {\n        DependencyObject target = TargetElement;\n        if (target == null)\n            return;\n\n        Debug.Assert(ParentMultiBinding.Converter != null || !String.IsNullOrEmpty(EffectiveStringFormat),\n                \"MultiBindingExpression should not exist if its bind does not have a valid converter.\");","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/MultiBindingExpression.cs#L141-L177","documentation":"MultiBindingExpression.CreateBindingExpression throws ArgumentException when the target DependencyProperty cannot accept data binding: its FrameworkPropertyMetadata has IsDataBindingAllowed == false or the property is read-only. Applying SetBinding/SetMultiBinding to such a property is rejected with the property name in the message.","triggerScenarios":"Calling BindingOperations.SetBinding(d, dp, new MultiBinding(...)) where dp is a read-only dependency property (e.g. registered with ReadOnly) or has metadata blocking binding; using a MultiBinding on a property with FrameworkPropertyMetadata options like NotDataBindable.","commonSituations":"Targeting read-only properties such as ActualWidth/IsLoaded; typos choosing the wrong DependencyProperty field; custom controls that registered a property read-only but a template tries to bind it.","solutions":["Choose a writable, bindable dependency property as the binding target","If the property is read-only, bind a related writable property or use OneWayToSource on a different target","Check dp.ReadOnly and FrameworkPropertyMetadata.IsDataBindingAllowed before calling SetBinding"],"exampleFix":"// before\ntextBlock.SetBinding(TextBlock.ActualWidthProperty, multiBinding); // read-only\n// after\ntextBlock.SetBinding(TextBlock.WidthProperty, multiBinding); // bindable target","handlingStrategy":"validation","validationCode":"var md = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata;\nbool bindable = md != null && md.IsDataBindingAllowed && !dp.ReadOnly;","typeGuard":"bool IsBindable(DependencyObject d, DependencyProperty dp) => dp.GetMetadata(d.DependencyObjectType) is FrameworkPropertyMetadata md && md.IsDataBindingAllowed && !dp.ReadOnly;","tryCatchPattern":"try { BindingOperations.SetBinding(d, dp, multiBinding); } catch (ArgumentException ex) when (ex.ParamName == \"dp\") { /* property not bindable */ }","preventionTips":["Never target read-only DPs like ActualWidth or IsLoaded","Check IsDataBindingAllowed before SetBinding in generic helpers","Confirm the correct DependencyProperty field when several share a name"],"tags":["wpf","binding","dependency-property","invalid-argument"],"backgroundTag":"invalid-argument-value","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"}