{"record":{"id":"b5a6e85f29dc5eb0","repo":"dotnet/wpf","slug":"sr-propertynotsupported-itemscontrolautomationpeer","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/ItemsControlAutomationPeer.cs","lineNumber":235,"sourceCode":"            ItemsControl owner = this.Owner as ItemsControl;\n            ItemCollection items = owner.Items;\n            if(items != null)\n            {\n                if(GetPeerFromWeakRefStorage(itemPeer.Item) == null)\n                    WeakRefElementProxyStorage[itemPeer.Item] = wr;\n            }\n        }\n\n        ///\n        IRawElementProviderSimple IItemContainerProvider.FindItemByProperty(IRawElementProviderSimple startAfter, int propertyId, object value)\n        {\n            ResetChildrenCache();\n            // Checks if propertyId is valid else throws ArgumentException to notify it as invalid argument is being passed\n            if (propertyId != 0)\n            {\n                if (!IsPropertySupportedByControlForFindItem(propertyId))\n                {\n                    throw new ArgumentException(SR.PropertyNotSupported);\n                }\n            }\n\n            ItemsControl owner = (ItemsControl)Owner;\n\n            ItemCollection items = null;\n            if(owner != null)\n                items = owner.Items;\n\n            if (items != null && items.Count > 0)\n            {\n                ItemAutomationPeer startAfterItem = null;\n                if (startAfter != null)\n                {\n                    // get the peer corresponding to this provider\n                    startAfterItem = PeerFromProvider(startAfter) as ItemAutomationPeer;\n                    if(startAfterItem == null)\n                        return null;","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ItemsControlAutomationPeer.cs#L217-L253","documentation":"ItemsControlAutomationPeer.FindItemByProperty/GetChildrenCore path validates the propertyId passed by the UIA client: if a non-zero property id is given and it is not one of the properties supported by this control for find-item operations, it throws ArgumentException(SR.PropertyNotSupported). This tells the client the requested property cannot be used as a filter.","triggerScenarios":"Calling UI FindItemByProperty (IItemContainerProvider.FindItemByProperty) with a propertyId that the ItemsControl does not support for filtering (only AutomationIdProperty, NameProperty, etc. are typically supported).","commonSituations":"UIA clients using IItemContainerProvider to search items by a property like IsSelectedProperty or a custom property; generic test frameworks passing arbitrary AutomationProperty ids.","solutions":["Pass only properties supported for find-item (typically AutomationIdProperty or NameProperty) or null/0 to match any property.","Use FindFirst/TreeWalker with manual property comparison instead of FindItemByProperty for unsupported properties.","Catch ArgumentException and fall back to enumerating children and comparing the property yourself."],"exampleFix":"// before\ncontainer.FindItemByProperty(null, SelectionItemPattern.IsSelectedProperty, true); // unsupported\n// after\nvar item = container.FindItemByProperty(null, AutomationElement.AutomationIdProperty, targetId);\n","handlingStrategy":"validation","validationCode":"if (propertyId != 0 && propertyId != AutomationElement.AutomationIdProperty.Id && propertyId != AutomationElement.NameProperty.Id) throwSkipFind();","typeGuard":"bool IsSupportedFindProperty(int id) => id == 0 || id == AutomationElement.AutomationIdProperty.Id || id == AutomationElement.NameProperty.Id;","tryCatchPattern":"try { container.FindItemByProperty(start, prop, value); } catch (ArgumentException) { /* enumerate children manually */ }","preventionTips":["Only pass AutomationIdProperty or NameProperty to FindItemByProperty.","Pass null property to match all items.","Fall back to manual TreeWalker enumeration for other properties."],"tags":["wpf","ui-automation","invalid-argument","property-not-supported"],"backgroundTag":"invalid-argument-value","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"}