{"record":{"id":"9c2fcdc00423c41d","repo":"stride3d/stride","slug":"unable-to-find-property-propertyname-on-object-of-type","errorCode":null,"errorMessage":"Unable to find property '{PropertyName}' on object of type '{AssociatedObject.GetType().FullName}'.","messagePattern":"Unable to find property '(.+?)' on object of type '(.+?)'\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/Behaviors/OnPropertyChangedCommandBehavior.cs","lineNumber":80,"sourceCode":"        /// <summary>\n        /// Gets or set whether the command should be executed only when the source of the binding associated to the dependency property is updated.\n        /// </summary>\n        /// <remarks>If set to <c>true</c>, this property requires that a binding exists on the dependency property and that it has <see cref=\"Binding.NotifyOnSourceUpdated\"/> set to <c>true</c>.</remarks>\n        public bool ExecuteOnlyOnSourceUpdate { get { return (bool)GetValue(ExecuteOnlyOnSourceUpdateProperty); } set { SetValue(ExecuteOnlyOnSourceUpdateProperty, value.Box()); } }\n        \n        /// <summary>\n        /// Gets or sets whether the value of the property should be used as the parameter of the command to execute when the property is modified.\n        /// </summary>\n        public bool PassValueAsParameter { get { return (bool)GetValue(PassValueAsParameterProperty); } set { SetValue(PassValueAsParameterProperty, value.Box()); } }\n\n        protected override void OnAttached()\n        {\n            if (PropertyName == null)\n                throw new ArgumentException($\"The PropertyName property must be set on behavior '{GetType().FullName}'.\");\n\n            dependencyProperty = AssociatedObject.GetDependencyProperties(true).FirstOrDefault(dp => dp.Name == PropertyName);\n            if (dependencyProperty == null)\n                throw new ArgumentException($\"Unable to find property '{PropertyName}' on object of type '{AssociatedObject.GetType().FullName}'.\");\n\n            propertyWatcher.Attach(AssociatedObject);\n            // TODO: Register/Unregister handlers when the PropertyName changes\n            propertyWatcher.RegisterValueChangedHandler(dependencyProperty, OnPropertyChanged);\n            Binding.AddSourceUpdatedHandler(AssociatedObject, OnSourceUpdated);\n        }\n\n        protected override void OnDetaching()\n        {\n            propertyWatcher.Detach();\n            base.OnDetaching();\n        }\n\n        private void OnSourceUpdated(object sender, [NotNull] DataTransferEventArgs e)\n        {\n            if (ExecuteOnlyOnSourceUpdate && e.Property == dependencyProperty)\n            {\n                ExecuteCommand();","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/Behaviors/OnPropertyChangedCommandBehavior.cs#L62-L98","documentation":"After confirming PropertyName is non-null, OnPropertyChangedCommandBehavior resolves it via GetDependencyProperties(true).FirstOrDefault(dp => dp.Name == PropertyName). If no dependency property with that exact name exists on the associated object, it throws ArgumentException reporting the property name and the object's type.","triggerScenarios":"Attaching the behavior to a Button but setting PropertyName=\"IsChecked\" (a ToggleButton property); case mismatch like PropertyName=\"ischecked\"; attaching to a control type that doesn't expose the named dependency property; targeting a CLR-only property.","commonSituations":"Re-using a behavior XAML snippet across different controls without updating PropertyName; refactoring a control and renaming its dependency property; attaching the behavior in a shared style applied to multiple unrelated control types.","solutions":["Set PropertyName to a dependency property that exists on the attached control's type (e.g. \"IsChecked\" for CheckBox/ToggleButton, \"Text\" for TextBox).","Verify which element the behavior is attached to; move it or fix PropertyName if the wrong control type received it.","Match casing exactly — dp.Name comparison is case-sensitive.","For attached properties, use the registered name as dp.Name reports it."],"exampleFix":"<!-- before: Button has no IsChecked property -->\n<Button Command=\"{Binding Submit}\">\n  <i:Interaction.Behaviors>\n    <b:OnPropertyChangedCommandBehavior PropertyName=\"IsChecked\" Command=\"{Binding Submit}\" />\n  </i:Interaction.Behaviors>\n</Button>\n\n<!-- after -->\n<CheckBox IsChecked=\"{Binding Accepted}\">\n  <i:Interaction.Behaviors>\n    <b:OnPropertyChangedCommandBehavior PropertyName=\"IsChecked\" Command=\"{Binding AcceptedChanged}\" />\n  </i:Interaction.Behaviors>\n</CheckBox>","handlingStrategy":"validation","validationCode":"bool ok = host.GetDependencyProperties(true).Any(dp => dp.Name == behavior.PropertyName);\nif (!ok) throw new InvalidOperationException($\"{host.GetType().Name} has no dependency property '{behavior.PropertyName}'.\");","typeGuard":"static bool HasDependencyProperty(DependencyObject o, string name) =>\n    o?.GetDependencyProperties(true).Any(dp => dp.Name == name) == true;","tryCatchPattern":"try { AttachBehavior(behavior, host); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Unable to find property\")) { log.Error($\"Wrong PropertyName '{behavior.PropertyName}' for {host.GetType().Name}\"); }","preventionTips":["Check the control's public dependency properties before choosing PropertyName.","Do not share behavior XAML across different control types without updating PropertyName.","Keep casing identical to the registered dependency property name."],"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"}