{"record":{"id":"3de5f31910dd61cd","repo":"stride3d/stride","slug":"propertyname-must-be-set","errorCode":null,"errorMessage":"PropertyName must be set.","messagePattern":"PropertyName must be set\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/Behaviors/OnFocusBindingInterruptionBehavior.cs","lineNumber":36,"sourceCode":"    /// <remarks>The host element must be of type <c>UIElement</c> and the <c>DependencyProprty</c> defined by PropertyName property must be set to a <c>BindingBase</c> object.</remarks>\n    public class OnFocusBindingInterruptionBehavior : Behavior<DependencyObject>\n    {\n        private IDisposable subscriber;\n        private DependencyProperty property;\n\n        /// <summary>\n        /// Gets or sets the name of the DependencyProperty on which the Binding has to be interrupted.\n        /// </summary>\n        public string PropertyName { get; set; }\n        /// <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(","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/Behaviors/OnFocusBindingInterruptionBehavior.cs#L18-L54","documentation":"OnFocusBindingInterruptionBehavior interrupts a WPF binding on a dependency property while the element has keyboard focus, so typed input is not overwritten by binding updates. In OnAttached it first validates that the PropertyName behavior property is a non-empty, non-whitespace string. If it was never set (or is blank), it throws ArgumentException to fail fast instead of producing a silently non-functional behavior.","triggerScenarios":"Attaching OnFocusBindingInterruptionBehavior via XAML or code without setting its PropertyName property, e.g. <behaviors:OnFocusBindingInterruptionBehavior Binding=\"{Binding SomePath}\"/> with no PropertyName attribute, or setting PropertyName=\"\" or whitespace.","commonSituations":"Copying the behavior usage from an example but deleting the PropertyName attribute; binding PropertyName to a resource/ViewModel value that resolves to empty at attach time; renaming the target property and clearing the attribute accidentally.","solutions":["Set the PropertyName property on the behavior to the exact name of the target dependency property, e.g. PropertyName=\"Text\".","Verify PropertyName is not empty or whitespace at runtime before the element loads (e.g. if set via binding/data, ensure it evaluates before OnAttached).","If the behavior is not needed, remove it from the interaction Behaviors collection entirely instead of leaving an unconfigured instance."],"exampleFix":"<!-- before -->\n<i:Interaction.Behaviors>\n  <b:OnFocusBindingInterruptionBehavior Binding=\"{Binding Name}\" />\n</i:Interaction.Behaviors>\n\n<!-- after -->\n<i:Interaction.Behaviors>\n  <b:OnFocusBindingInterruptionBehavior PropertyName=\"Text\" Binding=\"{Binding Name}\" />\n</i:Interaction.Behaviors>","handlingStrategy":"validation","validationCode":"var behavior = new OnFocusBindingInterruptionBehavior();\nif (string.IsNullOrWhiteSpace(behavior.PropertyName))\n    throw new InvalidOperationException(\"Set PropertyName before attaching OnFocusBindingInterruptionBehavior.\");","typeGuard":null,"tryCatchPattern":"try { BehaviorCollectionHelper.Attach(behavior); }\ncatch (ArgumentException ex) when (ex.Message == \"PropertyName must be set.\") { log.Error(\"Behavior misconfigured: PropertyName missing\"); }","preventionTips":["Always pair PropertyName and Binding attributes when using OnFocusBindingInterruptionBehavior in XAML.","Create a reusable XAML snippet/style that includes both required properties.","Review behaviors during code review for both required attributes before merging."],"tags":["wpf","behavior","configuration","argument"],"backgroundTag":"missing-required-argument","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"}