{"record":{"id":"cb7c6d7149014b14","repo":"dotnet/wpf","slug":"sr-propertynotsupported","errorCode":null,"errorMessage":"SR.PropertyNotSupported","messagePattern":"SR\\.PropertyNotSupported","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/CalendarAutomationPeer.cs","lineNumber":528,"sourceCode":"                    throw new InvalidOperationException(SR.CalendarNamePropertyValueNotValid);\n                }\n\n                currentMode = (startAfterDatePeer != null) ? startAfterDatePeer.ButtonMode : OwningCalendar.DisplayMode;\n            }\n            else if (propertyId == 0 || propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id)\n            {\n                // propertyId = 0 returns the button next to the startAfter or the DisplayDate if startAfter is null\n                // All items here are buttons, so same behaviour as propertyId = 0\n                if (propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id && (int)value != ControlType.Button.Id)\n                {\n                    return null;\n                }\n                currentMode = (startAfterDatePeer != null) ? startAfterDatePeer.ButtonMode : OwningCalendar.DisplayMode;\n                nextDate = GetNextDate(startAfterDatePeer, currentMode);\n            }\n            else\n            {\n                throw new ArgumentException(SR.PropertyNotSupported);\n            }\n\n            if (nextDate.HasValue)\n            {\n                AutomationPeer nextPeer = GetOrCreateDateTimeAutomationPeer(nextDate.Value, currentMode);\n                if (nextPeer != null)\n                {\n                    return ProviderFromPeer(nextPeer);\n                }\n            }\n            return null;\n        }\n\n        private DateTime? GetNextDate(DateTimeAutomationPeer currentDatePeer, CalendarMode currentMode)\n        {\n            DateTime? nextDate = null;\n\n            DateTime startDate = (currentDatePeer != null) ? currentDatePeer.Date : OwningCalendar.DisplayDate;","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/CalendarAutomationPeer.cs#L510-L546","documentation":"CalendarAutomationPeer.FindItemByProperty only supports searching by null propertyId (first item), ControlTypeProperty, or NameProperty. Any other AutomationProperty id reaches the final else branch and throws ArgumentException(SR.PropertyNotSupported), per the IItemContainerProvider contract that unsupported search properties are rejected.","triggerScenarios":"Calling FindItemByProperty(startAfter, property, value) with a property such as AutomationIdProperty, HelpTextProperty, or any non-ControlType/non-Name AutomationProperty.","commonSituations":"Generic automation search helpers passing arbitrary property ids; migrating code that assumed all AutomationElement properties were searchable; test frameworks filtering calendar items by AutomationId.","solutions":["Restrict searches to AutomationElementIdentifiers.ControlTypeProperty, NameProperty, or null (propertyId == 0).","To filter by other attributes (e.g. AutomationId), enumerate the calendar's child automation peers and filter in client code.","Catch ArgumentException around FindItemByProperty and fall back to manual child enumeration.","Use client-side UIA FindFirst with TreeWalker conditions instead of the provider-level method for arbitrary properties."],"exampleFix":"// before\nvar item = peer.FindItemByProperty(null, AutomationElement.AutomationIdProperty, \"day1\"); // not supported\n// after\nvar item = peer.FindItemByProperty(null, AutomationElement.NameProperty, \"Monday, May 1, 2024\");","handlingStrategy":"validation","validationCode":"if (!(property == null || property == AutomationElement.NameProperty || property == AutomationElement.ControlTypeProperty))\n    throw new ArgumentException(\"Calendar FindItemByProperty supports only Name, ControlType, or null.\");","typeGuard":null,"tryCatchPattern":"try { var item = peer.FindItemByProperty(start, property, value); }\ncatch (ArgumentException)\n{\n    // enumerate child peers and filter manually\n}","preventionTips":["Restrict FindItemByProperty to NameProperty/ControlTypeProperty/null.","Use TreeWalker or client-side FindFirst with conditions for other properties.","Document supported search properties in automation helpers."],"tags":["wpf","ui-automation","calendar","unsupported-property","argument-exception"],"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"}