dotnet/wpf · error · NotImplementedException

System.NotImplementedException()

Error message

System.NotImplementedException()

What it means

InputScope.AddChild is part of the IAddChild infrastructure used by XAML parsers to add child content to an element. For InputScope the implementation was never written, so any call throws NotImplementedException unconditionally. This signals that InputScope does not support programmatic/XAML child-object addition.

Solutions

  1. Do not add child objects to InputScope; set properties such as Names or Phrases collections directly instead
  2. If building input scopes in code, use scope.Names.Add(new InputScopeName(...)) or scope.Phrases.Add(new InputScopePhrase(...))
  3. Replace XAML child-element syntax under InputScope with property-element syntax for Names/Phrases

Example fix

// before
scope.AddChild(new InputScopeName { NameValue = InputScopeNameValue.Number });
// after
scope.Names.Add(new InputScopeName { NameValue = InputScopeNameValue.Number });
Defensive patterns

Strategy: validation

Validate before calling

bool canAddChild = obj is IAddChild ia && !(obj is System.Windows.Input.InputScope);

Try / catch

try { scope.AddChild(child); } catch (NotImplementedException) { /* use scope.Names/Phrases instead */ }

Prevention

When it happens

Trigger: Calling InputScope.AddChild(object) directly, or a XAML processor invoking IAddChild.AddChild when parsing <InputScope> with child object elements.

Common situations: Migrating legacy XAML that declared child elements under InputScope; tools or custom markup writers that use IAddChild generically on any object.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputScope.cs:142

        ///<summary>
        /// Constructor that takes name
        ///</summary>
        public InputScopeName(InputScopeNameValue nameValue)
        {
            _nameValue = nameValue;
        }


#region implementation of IAddChild 
        ///<summary>
        /// Called to Add the object as a Child. For InputScopePhrase tag this is ignored
        ///</summary>
        ///<param name="value">
        /// Object to add as a child
        ///</param>
        public void AddChild(object value) 
        {
            throw new System.NotImplementedException();
        }

        /// <summary>
        ///  if text is present between InputScopePhrase tags, the text is added as a phrase name 
        /// </summary>
        ///<param name="name">
        /// Text string to add
        ///</param>
        public void AddText(string name)
        {
            // throw new System.NotImplementedException();
        }

#endregion IAddChild

#endregion Public Methods

#region class public properties

View on GitHub (pinned to 81131a70a4)