{"record":{"id":"70f64225613615b5","repo":"dotnet/wpf","slug":"sr-progressbarreadonly","errorCode":null,"errorMessage":"SR.ProgressBarReadOnly","messagePattern":"SR\\.ProgressBarReadOnly","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ProgressBarAutomationPeer.cs","lineNumber":47,"sourceCode":"        ///\n        public override object GetPattern(PatternInterface patternInterface)\n        {\n            // Indeterminate ProgressBar should not support RangeValue pattern\n            if (patternInterface == PatternInterface.RangeValue && ((ProgressBar)Owner).IsIndeterminate)\n                return null;\n\n            return base.GetPattern(patternInterface);\n        }\n\n        /// <summary>\n        /// Request to set the value that this UI element is representing\n        /// </summary>\n        /// <param name=\"val\">Value to set the UI to, as an object</param>\n        /// <returns>true if the UI element was successfully set to the specified value</returns>\n        //[CodeAnalysis(\"AptcaMethodsShouldOnlyCallAptcaMethods\")] //Tracking Bug: 29647\n        void IRangeValueProvider.SetValue(double val)\n        {\n            throw new InvalidOperationException(SR.ProgressBarReadOnly);\n        }\n\n        ///<summary>Indicates that the value can only be read, not modified.\n        ///returns True if the control is read-only</summary>\n        bool IRangeValueProvider.IsReadOnly\n        {\n            get\n            {\n                return true;\n            }\n        }\n\n        ///<summary>Value of a Large Change</summary>\n        double IRangeValueProvider.LargeChange\n        {\n            get\n            {\n                return double.NaN;","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ProgressBarAutomationPeer.cs#L29-L65","documentation":"IRangeValueProvider.SetValue on ProgressBarAutomationPeer unconditionally throws InvalidOperationException with SR.ProgressBarReadOnly because a ProgressBar is a read-only indicator — its value is driven by the application, never set by UIA clients. The peer also advertises IsReadOnly=true via the RangeValue pattern.","triggerScenarios":"Any UIA client call to RangeValuePattern.SetValue() on a ProgressBar, regardless of state — there is no code path that allows it.","commonSituations":"Automation scripts that treat progress bars like sliders and attempt to set progress; generic pattern-exercising test harnesses that call SetValue on every RangeValue-capable element.","solutions":["Do not set progress via UIA; update ProgressBar.Value (or the bound view-model property) from application code.","Use only RangeValuePattern.Value to read progress in tests; simulate work through the app's API/view-model instead.","Remove ProgressBar from the list of RangeValue targets in generic automation harnesses."],"exampleFix":"// before (test)\nrangeValuePattern.SetValue(50.0); // always throws\n// after\nvar current = rangeValuePattern.Value; // read-only\nviewModel.Progress = 50; // drive progress from the app","handlingStrategy":"validation","validationCode":"if (rangeValuePattern.IsReadOnly) { /* never call SetValue on progress bars */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never script SetValue against ProgressBar; read RangeValue only","Drive progress from application/view-model code in tests","Exclude read-only controls from generic pattern-exercising harnesses"],"tags":["wpf","uiautomation","progressbar","read-only"],"backgroundTag":"read-only-property","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}