{"record":{"id":"1875fc548b05bff1","repo":"dotnet/wpf","slug":"elementnotenabledexception-windowslistview","errorCode":null,"errorMessage":"ElementNotEnabledException","messagePattern":"ElementNotEnabledException","errorType":"exception","errorClass":"ElementNotEnabledException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsListView.cs","lineNumber":605,"sourceCode":"        bool ISelectionProvider.IsSelectionRequired\n        {\n            get\n            {\n                return false;\n            }\n        }\n\n\n        #endregion SelectionPattern\n\n        #region ScrollPattern\n\n        void IScrollProvider.Scroll (ScrollAmount horizontalAmount, ScrollAmount verticalAmount)\n        {\n            // Make sure that the control is enabled\n            if (!SafeNativeMethods.IsWindowEnabled(_hwnd))\n            {\n                throw new ElementNotEnabledException();\n            }\n\n            WindowScroll.Scroll (_hwnd, horizontalAmount, verticalAmount, true);\n        }\n\n        void IScrollProvider.SetScrollPercent (double horizontalPercent, double verticalPercent)\n        {\n            // Make sure that the control is enabled\n            if (!SafeNativeMethods.IsWindowEnabled(_hwnd))\n            {\n                throw new ElementNotEnabledException();\n            }\n\n            // get the \"full size\" of the list-view\n            int size = ApproximateViewRect (_hwnd);\n\n            // ApproximateViewRect adds the window edge size, substract it\n            int cx = NativeMethods.Util.LOWORD (size) /*- 2 * UnsafeNativeMethods.GetSystemMetrics (NativeMethods.SM_CXBORDER)*/;","sourceCodeStart":587,"sourceCodeEnd":623,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsListView.cs#L587-L623","documentation":"WindowsListView's IScrollProvider.Scroll throws ElementNotEnabledException when the list-view HWND is disabled. Per the Scroll pattern contract, scrolling a disabled control is not allowed, so the provider checks IsWindowEnabled before delegating to WindowScroll.Scroll.","triggerScenarios":"Calling the Scroll pattern with any horizontal/vertical ScrollAmount on a list-view element whose window is disabled (WS_DISABLED) at call time.","commonSituations":"Automating a read-only/disabled list view; the dialog disables the list during long operations; race between app disabling the control and the automation scroll request.","solutions":["Check element IsEnabled (or Scroll availability) before invoking Scroll.","Wait for the control to be re-enabled, then retry the scroll.","Catch ElementNotEnabledException and fall back to keyboard-based scrolling if applicable.","Fix the host app so the list view remains enabled when scrolling is expected."],"exampleFix":"// before\n((ScrollPattern)lv.GetCurrentPattern(ScrollPattern.Pattern)).Scroll(ScrollAmount.SmallIncrement, ScrollAmount.NoAmount);\n// after\nvar sp = (ScrollPattern)lv.GetCurrentPattern(ScrollPattern.Pattern);\nif (lv.Current.IsEnabled) sp.Scroll(ScrollAmount.SmallIncrement, ScrollAmount.NoAmount);","handlingStrategy":"validation","validationCode":"if (!element.Current.IsEnabled) { /* wait or skip */ } else { ((ScrollPattern)element.GetCurrentPattern(ScrollPattern.Pattern)).Scroll(h, v); }","typeGuard":null,"tryCatchPattern":"try { scrollPattern.Scroll(h, v); } catch (ElementNotEnabledException) { /* control disabled */ }","preventionTips":["Check IsEnabled before scrolling","Poll for control re-enable after long app operations","Prefer keyboard scrolling fallback for disabled controls"],"tags":["ui-automation","scroll-pattern","element-not-enabled"],"backgroundTag":"feature-not-enabled","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"}