{"record":{"id":"d64fc813a59cd413","repo":"dotnet/wpf","slug":"elementnotenabledexception-scrollviewerautomationpeer","errorCode":null,"errorMessage":"ElementNotEnabledException","messagePattern":"ElementNotEnabledException","errorType":"exception","errorClass":"ElementNotEnabledException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ScrollViewerAutomationPeer.cs","lineNumber":76,"sourceCode":"        }\n\n\n        //-------------------------------------------------------------------\n        //\n        //  IScrollProvider\n        //\n        //-------------------------------------------------------------------\n\n        /// <summary>\n        /// Request to scroll horizontally and vertically by the specified amount.\n        /// The ability to call this method and simultaneously scroll horizontally\n        /// and vertically provides simple panning support.\n        /// </summary>\n        /// <see cref=\"IScrollProvider.Scroll\"/>\n        void IScrollProvider.Scroll(ScrollAmount horizontalAmount, ScrollAmount verticalAmount)\n        {\n            if(!IsEnabled())\n                throw new ElementNotEnabledException();\n\n            bool scrollHorizontally = (horizontalAmount != ScrollAmount.NoAmount);\n            bool scrollVertically = (verticalAmount != ScrollAmount.NoAmount);\n\n            ScrollViewer owner = (ScrollViewer)Owner;\n\n            if (scrollHorizontally && !HorizontallyScrollable || scrollVertically && !VerticallyScrollable)\n            {\n                throw new InvalidOperationException(SR.UIA_OperationCannotBePerformed);\n            }\n\n            switch (horizontalAmount)\n            {\n                case ScrollAmount.LargeDecrement:\n                    owner.PageLeft();\n                    break;\n                case ScrollAmount.SmallDecrement:\n                    owner.LineLeft();","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ScrollViewerAutomationPeer.cs#L58-L94","documentation":"ScrollViewerAutomationPeer's IScrollProvider.Scroll throws ElementNotEnabledException when the ScrollViewer is disabled. The Scroll pattern (like all UIA patterns) refuses to operate on a disabled element.","triggerScenarios":"Calling Scroll(horizontalAmount, verticalAmount) on the Scroll pattern when the ScrollViewer owner has IsEnabled=false.","commonSituations":"UIA scripts scrolling a viewer inside a disabled container/panel; test automation running while the window is disabled (e.g. modal busy state).","solutions":["Enable the ScrollViewer (and its ancestors) before scrolling","Verify IsEnabled before calling Scroll","Catch ElementNotEnabledException and wait/retry until the control is enabled"],"exampleFix":"// before\nscrollPattern.Scroll(ScrollAmount.SmallIncrement, ScrollAmount.NoAmount);\n// after\nif (scrollViewer.IsEnabled)\n    scrollPattern.Scroll(ScrollAmount.SmallIncrement, ScrollAmount.NoAmount);","handlingStrategy":"validation","validationCode":"if (!scrollViewer.IsEnabled) { /* wait or enable */ }","typeGuard":"static bool CanScroll(ScrollViewer sv) => sv?.IsEnabled == true;","tryCatchPattern":"try { scrollProvider.Scroll(h, v); }\ncatch (ElementNotEnabledException) { /* retry after enabled */ }","preventionTips":["Check IsEnabled including ancestors before scrolling","Wait for busy/modal states to clear in automation","Use WaitForInputIdle style waits in tests","Catch UIA_E_ELEMENTNOTENABLED in clients"],"tags":["wpf","ui-automation","disabled-element"],"backgroundTag":"authentication-required","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}