{"record":{"id":"cbba739115a4b3a2","repo":"stride3d/stride","slug":"impossible-to-find-property-named-propertyname-on-object","errorCode":null,"errorMessage":"Impossible to find property named '{PropertyName}' on object typed '{AssociatedObject.GetType()}'.","messagePattern":"Impossible to find property named '(.+?)' on object typed '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/Behaviors/OnFocusBindingInterruptionBehavior.cs","lineNumber":46,"sourceCode":"        /// <summary>\n        /// Gets or sets the binding to apply on the Host property defined by 'PropertyName' behavior property.\n        /// </summary>\n        public BindingBase Binding { get; set; }\n\n        protected override void OnAttached()\n        {\n            if (string.IsNullOrWhiteSpace(PropertyName))\n                throw new ArgumentException(\"PropertyName must be set.\");\n\n            if (Binding == null)\n            {\n                throw new ArgumentException($\"Binding must be set for {PropertyName} property of host '{AssociatedObject}' on behavior '{GetType().FullName}'.\");\n            }\n\n            property = AssociatedObject.GetDependencyProperties(true).FirstOrDefault(dp => dp.Name == PropertyName);\n\n            if (property == null /* need to check DesignMode as well ? */)\n                throw new InvalidOperationException($\"Impossible to find property named '{PropertyName}' on object typed '{AssociatedObject.GetType()}'.\");\n\n            if ((Binding is Binding) == false)\n                throw new InvalidOperationException(\"Not supported binding type.\");\n\n            var element = AssociatedObject as FrameworkElement;\n            if (element == null)\n            {\n                throw new InvalidOperationException(\n                    $\"Behavior of type '{GetType()}' must be bound to objects of type '{typeof(FrameworkElement)}'. (currently bound to object typed '{AssociatedObject.GetType()}')\");\n            }\n\n            BindingOperations.SetBinding(AssociatedObject, property, Binding);\n\n            // subscribe to *Focus events\n            element.GotFocus += OnHostGotFocus;\n            element.LostFocus += OnHostLostFocus;\n\n            subscriber = new AnonymousDisposable(() =>","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/Behaviors/OnFocusBindingInterruptionBehavior.cs#L28-L64","documentation":"The behavior resolves PropertyName against the attached object's dependency properties using GetDependencyProperties(true) and FirstOrDefault. When no dependency property with that exact name exists on the associated object, it throws InvalidOperationException naming the missing property and the object's type.","triggerScenarios":"Attaching the behavior to a TextBox but setting PropertyName=\"Value\" (that's a RangeBase property), PropertyName with different casing than the actual dependency property name (lookup is name-exact), or attaching to an object whose dependency property is attached/inherited but not registered with a matching name.","commonSituations":"Renaming the target control (e.g. TextBox to PasswordBox) without updating PropertyName; typos or case mismatches like propertyname=\"Text\"; assuming the behavior works on plain CLR properties instead of dependency properties.","solutions":["Correct PropertyName to the exact dependency property name on the attached control (e.g. \"Text\" for TextBox, \"Value\" for Slider).","Verify the behavior is attached to the intended element in XAML (the property must exist on THAT object's type).","Check casing: property lookup compares dp.Name exactly; match the registered property name's casing.","If the target is only a CLR property, bind via a different mechanism or wrap it in a dependency property."],"exampleFix":"<!-- before: TextBox has no 'Value' dependency property -->\n<TextBox Text=\"{Binding Name}\">\n  <i:Interaction.Behaviors>\n    <b:OnFocusBindingInterruptionBehavior PropertyName=\"Value\" Binding=\"{Binding Name}\" />\n  </i:Interaction.Behaviors>\n</TextBox>\n\n<!-- after -->\n<TextBox Text=\"{Binding Name}\">\n  <i:Interaction.Behaviors>\n    <b:OnFocusBindingInterruptionBehavior PropertyName=\"Text\" Binding=\"{Binding Name}\" />\n  </i:Interaction.Behaviors>\n</TextBox>","handlingStrategy":"validation","validationCode":"bool hasProp = target.GetDependencyProperties(true).Any(dp => dp.Name == \"Text\");\nif (!hasProp) throw new InvalidOperationException(\"Target has no 'Text' dependency property for the behavior.\");","typeGuard":"static bool HasDependencyProperty(DependencyObject o, string name) =>\n    o != null && o.GetDependencyProperties(true).Any(dp => dp.Name == name);","tryCatchPattern":"try { AttachBehavior(behavior, target); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Impossible to find property named\")) { log.Error($\"{target.GetType().Name} lacks property {behavior.PropertyName}\"); }","preventionTips":["Confirm the property is a dependency property on the attached control's exact type before writing PropertyName.","Match casing exactly — dp.Name comparison is case-sensitive.","Keep behavior XAML next to the control declaration so type and property are reviewed together."],"tags":["wpf","behavior","property-not-found","configuration"],"backgroundTag":"resource-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}