{"record":{"id":"089bfec9d75f028c","repo":"dotnet/wpf","slug":"sr-propertynotsupported-datagriditemautomationpeer","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/DataGridItemAutomationPeer.cs","lineNumber":135,"sourceCode":"                    }\n                }\n            }\n\n            return base.GetPeerFromPointCore(point);\n        }\n\n        #endregion\n\n        #region IItemContainerProvider\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 (!SelectorAutomationPeer.IsPropertySupportedByControlForFindItemInternal(propertyId))\n                {\n                    throw new ArgumentException(SR.PropertyNotSupported);\n                }\n            }\n\n\n            IList<DataGridColumn> columns = OwningDataGrid.Columns;\n\n            if (columns != null && columns.Count > 0)\n            {\n                DataGridCellItemAutomationPeer startAfterItem = null;\n                if (startAfter != null)\n                {\n                    // get the peer corresponding to this provider\n                    startAfterItem = PeerFromProvider(startAfter) as DataGridCellItemAutomationPeer;\n                }\n\n                // startIndex refers to the index of the item just after startAfterItem\n                int startIndex = 0;\n                if (startAfterItem != null)","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/DataGridItemAutomationPeer.cs#L117-L153","documentation":"DataGridItemAutomationPeer.FindItemByProperty throws ArgumentException when propertyId is non-zero and is not one of the properties the control supports for UIA item searches. The library validates the property up front rather than silently returning no results.","triggerScenarios":"Calling FindItemByProperty on a DataGrid row peer with a propertyId that is not supported by SelectorAutomationPeer.IsPropertySupportedByControlForFindItemInternal (e.g. an automation property unrelated to item search).","commonSituations":"UIA client code written against a different control type (which supports more properties) reused against DataGrid rows; hard-coded property IDs from other frameworks.","solutions":["Query SelectorAutomationPeer.IsPropertySupportedByControlForFindItemInternal(propertyId) before the call.","Pass 0 for propertyId to search without property filtering, then filter manually.","Catch ArgumentException and retry with propertyId = 0.","Use only documented automation properties (e.g. NameProperty) supported for FindItemByProperty on this control."],"exampleFix":"// before\nrowPeer.FindItemByProperty(null, SelectionItemPattern.Pattern.Id, null); // unsupported\n// after\nint propertyId = AutomationElement.NameProperty.Id;\nvar item = SelectorAutomationPeer.IsPropertySupportedByControlForFindItemInternal(propertyId)\n    ? rowPeer.FindItemByProperty(null, propertyId, null)\n    : rowPeer.FindItemByProperty(null, 0, null);","handlingStrategy":"validation","validationCode":"if (propertyId != 0 && !SelectorAutomationPeer.IsPropertySupportedByControlForFindItemInternal(propertyId))\n    propertyId = 0;","typeGuard":null,"tryCatchPattern":"try { return peer.FindItemByProperty(start, propertyId, value); }\ncatch (ArgumentException) { return peer.FindItemByProperty(start, 0, value); }","preventionTips":["Only use automation properties documented as supported for FindItemByProperty on this control","Default to propertyId 0 and filter results client-side","Centralize property-id constants instead of hard-coding per-control IDs"],"tags":["wpf","uiautomation","datagrid","argument"],"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"}