stride3d/stride · error · InvalidOperationException

Not supported binding type.

Error message

Not supported binding type.

What it means

OnFocusBindingInterruptionBehavior calls BindingOperations.SetBinding, which only accepts System.Windows.Data.Binding, not derived/other BindingBase types like PriorityBinding or MultiBinding. When the supplied Binding is not a plain Binding, the behavior throws InvalidOperationException('Not supported binding type.').

Solutions

  1. Replace MultiBinding/PriorityBinding with a single Binding; move converter logic into a value converter on that one binding.
  2. Flatten multiple sources via the ViewModel (expose a computed property) and bind that single property.
  3. If multi-binding is essential, modify or subclass the behavior to handle the desired BindingBase type explicitly.

Example fix

<!-- before -->
<b:OnFocusBindingInterruptionBehavior PropertyName="Text">
  <b:OnFocusBindingInterruptionBehavior.Binding>
    <MultiBinding Converter="{StaticResource MyConv}">
      <Binding Path="First" />
      <Binding Path="Last" />
    </MultiBinding>
  </b:OnFocusBindingInterruptionBehavior.Binding>
</b:OnFocusBindingInterruptionBehavior>

<!-- after: expose FullName in the ViewModel and use a plain Binding -->
<b:OnFocusBindingInterruptionBehavior PropertyName="Text" Binding="{Binding FullName}" />
Defensive patterns

Strategy: type-guard

Validate before calling

if (behavior.Binding is not System.Windows.Data.Binding)
    throw new InvalidOperationException("OnFocusBindingInterruptionBehavior requires a plain Binding, not MultiBinding/PriorityBinding.");

Type guard

static bool IsPlainBinding(BindingBase b) => b is System.Windows.Data.Binding;

Try / catch

try { AttachBehavior(behavior, target); }
catch (InvalidOperationException ex) when (ex.Message == "Not supported binding type.") { log.Error("Use a single System.Windows.Data.Binding with this behavior"); }

Prevention

When it happens

Trigger: Setting the behavior's Binding property to a <MultiBinding> or <PriorityBinding>, or any custom BindingBase subclass; only System.Windows.Data.Binding instances pass the `(Binding is Binding)` check.

Common situations: Needing multiple sources for the interrupted value and reaching for MultiBinding without realizing this behavior only supports single-source Binding; refactoring a plain Binding into MultiBinding for a converter chain.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

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

        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(() =>
            {
                // unsubscribe from *Focus events
                element.LostFocus -= OnHostLostFocus;

View on GitHub (pinned to 96fad776d2)