{"record":{"id":"35094066db1ec5c9","repo":"dotnet/wpf","slug":"sr-operationcannotbeperformed-windowscalendar","errorCode":null,"errorMessage":"SR.OperationCannotBePerformed","messagePattern":"SR\\.OperationCannotBePerformed","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/UnsupportedAutomationProxies/WindowsCalendar.cs","lineNumber":359,"sourceCode":"            return base.ElementProviderFromPoint (x, y);\n        }\n\n        #endregion\n\n        #region Scroll Pattern\n\n        // Request to scroll Horizontally and vertically by the specified amount\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            if ((int)verticalPercent != (int)ScrollPattern.NoScroll)\n            {\n                throw new InvalidOperationException(SR.OperationCannotBePerformed);\n            }\n            else if ((int)horizontalPercent == (int)ScrollPattern.NoScroll)\n            {\n                return;\n            }\n            else if (horizontalPercent < 0 || horizontalPercent > 100)\n            {\n                throw new ArgumentOutOfRangeException(\"horizontalPercent\", SR.ScrollBarOutOfRange);\n            }\n\n            int cDisplayedMonths = GetMonthCount();\n            DateTime [] dateRange =\n                CreateDateTimeFromSystemTime (GetRawValue (_hwnd, CalendarData.Range));\n            int cMonths = (dateRange [1].Year - dateRange [0].Year) * 12\n                            + (dateRange [1].Month - dateRange [0].Month) + 1;\n\n            if (cMonths <= cDisplayedMonths)\n            {","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/UnsupportedAutomationProxies/WindowsCalendar.cs#L341-L377","documentation":"The WindowsCalendar proxy cannot scroll vertically: if verticalPercent is anything other than ScrollPattern.NoScroll, SetScrollPercent throws InvalidOperationException(SR.OperationCannotBePerformed). The month calendar supports only horizontal scrolling.","triggerScenarios":"Calling IScrollProvider.SetScrollPercent with a verticalPercent other than ScrollPattern.NoScroll (e.g. 50) on a month-calendar element.","commonSituations":"Generic scroll automation scripts that set both axes on every control; assuming the calendar behaves like a scrollable list.","solutions":["Pass ScrollPattern.NoScroll for verticalPercent and only scroll horizontally.","Query VerticalScrollPercent first; if it reports NoScroll, skip the vertical axis.","Catch InvalidOperationException and handle vertical scrolling via another mechanism (keyboard/selection)."],"exampleFix":"// before\nscrollPattern.SetScrollPercent(50, 50);\n// after\nscrollPattern.SetScrollPercent(50, ScrollPattern.NoScroll);","handlingStrategy":"validation","validationCode":"if ((int)verticalPercent != (int)ScrollPattern.NoScroll)\n    throw new InvalidOperationException(\"WindowsCalendar does not support vertical scrolling\");","typeGuard":"bool SupportsVerticalScroll(IScrollProvider sp) => sp.VerticalScrollPercent != ScrollPattern.NoScroll;","tryCatchPattern":"try { scrollPattern.SetScrollPercent(h, v); }\ncatch (InvalidOperationException) { /* vertical not supported; scroll horizontally only */ }","preventionTips":["Pass ScrollPattern.NoScroll for unsupported axes","Read VerticalScrollPercent first to detect NoScroll capability","Use keyboard/selection navigation for vertical month movement"],"tags":["uiautomation","scroll-pattern","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}