{"record":{"id":"752233f7824f87fa","repo":"dotnet/wpf","slug":"sr-unsupportedproperty","errorCode":null,"errorMessage":"SR.UnsupportedProperty","messagePattern":"SR\\.UnsupportedProperty","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/ItemContainerPattern.cs","lineNumber":129,"sourceCode":"           return wrappedElement;\n        }\n\n        #endregion Public Methods\n\n       //------------------------------------------------------\n       //\n       //  Private Methods\n       //\n       //------------------------------------------------------\n\n       #region Private Methods\n\n        private object PropertyValueValidateAndMap(AutomationProperty property, object value)\n        {\n            AutomationPropertyInfo info;\n            if (!Schema.GetPropertyInfo(property, out info))\n            {\n                throw new ArgumentException(SR.UnsupportedProperty);\n            }\n\n            // Check type is appropriate: NotSupported is allowed against any property,\n            // null is allowed for any reference type (ie not for value types), otherwise\n            // type must be assignable from expected type.\n            Type expectedType = info.Type;\n            if (value != AutomationElement.NotSupported &&\n                ((value == null && expectedType.IsValueType)\n                || (value != null && !expectedType.IsAssignableFrom(value.GetType()))))\n            {\n                throw new ArgumentException(SR.Format(SR.PropertyConditionIncorrectType, property.ProgrammaticName, expectedType.Name));\n            }\n\n            // Some types are handled differently in managed vs unmanaged - handle those here...\n            if (value is AutomationElement)\n            {\n                // If this is a comparison against a Raw/LogicalElement,\n                // save the runtime ID instead of the element so that we","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/ItemContainerPattern.cs#L111-L147","documentation":"ItemContainerPattern.FindItemByProperty validates the supplied AutomationProperty via Schema.GetPropertyInfo; if the property is not a recognized UI Automation property, ArgumentException(SR.UnsupportedProperty) is thrown. The pattern can only search against properties registered in the UIA schema.","triggerScenarios":"Passing a custom AutomationProperty, a property from another provider framework, or a null/unknown identifier to FindItemByProperty(property, value).","commonSituations":"Hand-rolled AutomationProperty instances or properties from a newer UIA version not known to the client; mixing properties from different element registries; typos when selecting a property identifier.","solutions":["Use only properties from AutomationElement or its pattern identifier classes (e.g. AutomationElementIdentifiers)","Verify the property is a recognized UIA property before calling FindItemByProperty","Pass AutomationElement.NotSupported as the value to search on all items if filtering is unnecessary"],"exampleFix":"// before\nvar prop = AutomationProperty.LookupById(99999); // unknown/custom\npattern.FindItemByProperty(null, prop, \"x\"); // ArgumentException\n// after\npattern.FindItemByProperty(null, AutomationElement.NameProperty, \"x\");","handlingStrategy":"validation","validationCode":"static readonly HashSet<AutomationProperty> Known = new(){ AutomationElement.NameProperty, AutomationElement.AutomationIdProperty, AutomationElement.ControlTypeProperty /* ... */ };\nif (!Known.Contains(prop)) throw new InvalidOperationException(\"Unknown property for FindItemByProperty\");","typeGuard":"bool IsKnownUiaProperty(AutomationProperty p) => p == AutomationElement.NameProperty || p == AutomationElement.AutomationIdProperty || p == AutomationElement.ControlTypeProperty;","tryCatchPattern":"try { pattern.FindItemByProperty(null, prop, value); } catch (ArgumentException ex) { /* log unsupported property, fall back to enumeration */ }","preventionTips":["Only use properties from AutomationElement*/pattern identifier classes","Avoid hand-built AutomationProperty instances","Prefer AutomationElement.NotSupported value to match all items"],"tags":["uiautomation","itemcontainer-pattern","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"}