dotnet/wpf · error · ArgumentException

SR.ChildHasWrongType (formatted with type name…

Error message

SR.ChildHasWrongType (formatted with type name, "BindingBase", value type name)

What it means

MultiBinding's IAddChild.AddChild throws ArgumentException when the child added in XAML/object code is not a BindingBase (e.g. a Binding, MultiBinding, or PriorityBinding). MultiBinding children must all be bindings; anything else is rejected with the child's type name in the message.

Solutions

  1. Ensure every child of MultiBinding is a Binding, MultiBinding, or PriorityBinding (a BindingBase)
  2. In XAML, put bindings under <MultiBinding.Bindings> using <Binding .../> elements
  3. Verify the object you pass to AddChild is actually a binding, not a converter or value

Example fix

<!-- before -->
<MultiBinding Converter="{StaticResource conv}">
  <StaticResource ResourceKey="notABinding"/>
</MultiBinding>
<!-- after -->
<MultiBinding Converter="{StaticResource conv}">
  <Binding Path="FirstName"/>
  <Binding Path="LastName"/>
</MultiBinding>
Defensive patterns

Strategy: type-guard

Validate before calling

if (value is BindingBase b) ((IAddChild)multiBinding).AddChild(b); else throw new ArgumentException("child must be a BindingBase");

Type guard

bool IsBindingChild(object o) => o is BindingBase;

Try / catch

try { addChild(v); } catch (ArgumentException ex) when (ex.ParamName == "value") { /* wrong child type */ }

Prevention

When it happens

Trigger: Calling ((IAddChild)multiBinding).AddChild(value) with a non-BindingBase object; XAML markup placing a non-binding element directly under <MultiBinding> instead of <MultiBinding.Bindings> with binding children.

Common situations: XAML typo placing a converter, string, or other element as a direct child of MultiBinding; programmatic object-tree construction adding the wrong node type; refactoring that changed the child element without changing its type.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/dd528fb8810ec11d. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/MultiBinding.cs:56

    {
        _bindingCollection = new BindingCollection(this, new BindingCollectionChangedCallback(OnBindingCollectionChanged));
    }

#region IAddChild

    ///<summary>
    /// Called to Add the object as a Child.
    ///</summary>
    ///<param name="value">
    /// Object to add as a child - must have type BindingBase
    ///</param>
    void IAddChild.AddChild(Object value)
    {
        BindingBase binding = value as BindingBase;
        if (binding != null)
            Bindings.Add(binding);
        else
            throw new ArgumentException(SR.Format(SR.ChildHasWrongType, this.GetType().Name, "BindingBase", value.GetType().FullName), nameof(value));
    }

    ///<summary>
    /// Called when text appears under the tag in markup
    ///</summary>
    ///<param name="text">
    /// Text to Add to the Object
    ///</param>
    void IAddChild.AddText(string text)
    {
        XamlSerializerUtil.ThrowIfNonWhiteSpaceInAddText(text, this);
    }

#endregion IAddChild

    //------------------------------------------------------
    //
    //  Public Properties

View on GitHub (pinned to 81131a70a4)