dotnet/wpf · error · ElementNotEnabledException

ElementNotEnabledException

Error message

ElementNotEnabledException

What it means

GridSplitterAutomationPeer's ITransformProvider.Move throws ElementNotEnabledException when IsEnabled() returns false, i.e. the underlying GridSplitter control (or an ancestor) is disabled. UIA requires that transform operations be rejected with this specific exception when the element is not enabled.

Solutions

  1. Enable the GridSplitter (IsEnabled=true) and all disabled ancestors before calling Move.
  2. Check IsEnabled property on the UIA element before invoking the Transform pattern.
  3. Catch ElementNotEnabledException in the automation client and skip or defer the move.
  4. Fix application logic that leaves the splitter (or parent) disabled when it should be interactive.

Example fix

// before
((ITransformProvider)peer).Move(50, 0);
// after
if (peer.IsEnabled()) ((ITransformProvider)peer).Move(50, 0);
Defensive patterns

Strategy: validation

Validate before calling

bool canMove = peer.IsEnabled();
if (!canMove) throw new SkipTestException("GridSplitter disabled");

Try / catch

try { ((ITransformProvider)peer).Move(x, y); }
catch (ElementNotEnabledException) { /* enable control or abort */ }

Prevention

When it happens

Trigger: A UIA client invokes ITransformProvider.Move on a GridSplitterAutomationPeer whose Owner GridSplitter has IsEnabled=false (directly or inherited from a disabled ancestor).

Common situations: Test suites or assistive tech driving splitter movement while the window/panel containing the splitter is disabled; forgetting to re-enable the control after showing a loading overlay that disables it.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/GridSplitterAutomationPeer.cs:40

        /// 
        public override object GetPattern(PatternInterface patternInterface)
        {
            if (patternInterface == PatternInterface.Transform)
                return this;
            else
                return base.GetPattern(patternInterface); 
        }

        #region ITransformProvider

        bool ITransformProvider.CanMove { get { return true; } }
        bool ITransformProvider.CanResize { get { return false; } }
        bool ITransformProvider.CanRotate { get { return false; } }

        void ITransformProvider.Move(double x, double y)
        {
            if (!IsEnabled())
                throw new ElementNotEnabledException();

            if (double.IsInfinity(x) || double.IsNaN(x))
                throw new ArgumentOutOfRangeException(nameof(x));

            if (double.IsInfinity(y) || double.IsNaN(y))
                throw new ArgumentOutOfRangeException(nameof(y));

            ((GridSplitter)Owner).KeyboardMoveSplitter(x, y);
        }
        void ITransformProvider.Resize(double width, double height)
        {
            throw new InvalidOperationException(SR.UIA_OperationCannotBePerformed);
        }
        void ITransformProvider.Rotate(double degrees)
        {
            throw new InvalidOperationException(SR.UIA_OperationCannotBePerformed);
        }

View on GitHub (pinned to 81131a70a4)