stride3d/stride · error · InvalidOperationException

Impossible to find property named

Error message

Impossible to find property named '{PropertyName}' on object typed '{AssociatedObject.GetType()}'.

What it means

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.

Solutions

  1. Correct PropertyName to the exact dependency property name on the attached control (e.g. "Text" for TextBox, "Value" for Slider).
  2. Verify the behavior is attached to the intended element in XAML (the property must exist on THAT object's type).
  3. Check casing: property lookup compares dp.Name exactly; match the registered property name's casing.
  4. If the target is only a CLR property, bind via a different mechanism or wrap it in a dependency property.

Example fix

<!-- before: TextBox has no 'Value' dependency property -->
<TextBox Text="{Binding Name}">
  <i:Interaction.Behaviors>
    <b:OnFocusBindingInterruptionBehavior PropertyName="Value" Binding="{Binding Name}" />
  </i:Interaction.Behaviors>
</TextBox>

<!-- after -->
<TextBox Text="{Binding Name}">
  <i:Interaction.Behaviors>
    <b:OnFocusBindingInterruptionBehavior PropertyName="Text" Binding="{Binding Name}" />
  </i:Interaction.Behaviors>
</TextBox>
Defensive patterns

Strategy: validation

Validate before calling

bool hasProp = target.GetDependencyProperties(true).Any(dp => dp.Name == "Text");
if (!hasProp) throw new InvalidOperationException("Target has no 'Text' dependency property for the behavior.");

Type guard

static bool HasDependencyProperty(DependencyObject o, string name) =>
    o != null && o.GetDependencyProperties(true).Any(dp => dp.Name == name);

Try / catch

try { AttachBehavior(behavior, target); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Impossible to find property named")) { log.Error($"{target.GetType().Name} lacks property {behavior.PropertyName}"); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/cbba739115a4b3a2. Report an issue: GitHub.

Appendix: source

Thrown at sources/presentation/Stride.Core.Presentation.Wpf/Behaviors/OnFocusBindingInterruptionBehavior.cs:46

        /// <summary>
        /// Gets or sets the binding to apply on the Host property defined by 'PropertyName' behavior property.
        /// </summary>
        public BindingBase Binding { get; set; }

        protected override void OnAttached()
        {
            if (string.IsNullOrWhiteSpace(PropertyName))
                throw new ArgumentException("PropertyName must be set.");

            if (Binding == null)
            {
                throw new ArgumentException($"Binding must be set for {PropertyName} property of host '{AssociatedObject}' on behavior '{GetType().FullName}'.");
            }

            property = AssociatedObject.GetDependencyProperties(true).FirstOrDefault(dp => dp.Name == PropertyName);

            if (property == null /* need to check DesignMode as well ? */)
                throw new InvalidOperationException($"Impossible to find property named '{PropertyName}' on object typed '{AssociatedObject.GetType()}'.");

            if ((Binding is Binding) == false)
                throw new InvalidOperationException("Not supported binding type.");

            var element = AssociatedObject as FrameworkElement;
            if (element == null)
            {
                throw new InvalidOperationException(
                    $"Behavior of type '{GetType()}' must be bound to objects of type '{typeof(FrameworkElement)}'. (currently bound to object typed '{AssociatedObject.GetType()}')");
            }

            BindingOperations.SetBinding(AssociatedObject, property, Binding);

            // subscribe to *Focus events
            element.GotFocus += OnHostGotFocus;
            element.LostFocus += OnHostLostFocus;

            subscriber = new AnonymousDisposable(() =>

View on GitHub (pinned to 96fad776d2)