{"record":{"id":"52bf40c074b3eae0","repo":"dotnet/wpf","slug":"sr-propertynotsupported-52bf40","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/DataGridColumnHeadersPresenterAutomationPeer.cs","lineNumber":158,"sourceCode":"\n        ///<summary>\n        /// Find Childrend Peers based on Automation Properties.\n        /// Used to enable virtualization with automation.\n        ///\n        /// GetChildrenCore and FindItemByProperty are almost straight copies of the\n        /// ItemControlAutomationPeer code; however since DataGridColumHeaderPresenter\n        /// returns the Column.Header's as the items some specialized code was needed to\n        /// create and store peers.\n        ///</summary>\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            IList items = null;\n            if (owner != null)\n                items = OwningDataGrid.Columns;\n\n            if (items != null && items.Count > 0)\n            {\n                DataGridColumnHeaderItemAutomationPeer startAfterItem = null;\n                if (startAfter != null)\n                {\n                    // get the peer corresponding to this provider\n                    startAfterItem = PeerFromProvider(startAfter) as DataGridColumnHeaderItemAutomationPeer;\n                    if (startAfterItem == null)\n                        return null;","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/DataGridColumnHeadersPresenterAutomationPeer.cs#L140-L176","documentation":"DataGridColumnHeadersPresenterAutomationPeer.GetChildrenCore calls IsPropertySupportedByControlForFindItem(propertyId) for property-scoped find requests; if the requested automation property is not supported by this control, it throws ArgumentException with SR.PropertyNotSupported to signal the property id is invalid for find-item queries. (The method also resets its children cache before rebuilding the header peers.)","triggerScenarios":"A UI Automation client performs a FindFirst/FindAll with a property condition using a propertyId that the DataGridColumnHeadersPresenter control does not support (IsPropertySupportedByControlForFindItem returns false), while propertyId != 0; the provider layer then surfaces this ArgumentException.","commonSituations":"UIA search conditions referencing properties unavailable on headers presenter (e.g. value/selection properties); custom automation clients probing unsupported properties; property ids changed or misused across framework versions.","solutions":["Remove unsupported properties from the UIA FindItem/FindFirst property condition and search only with supported ids.","Catch ArgumentException from find calls and retry without the property condition.","Use property id 0 or supported properties (e.g. AutomationId, Name) when searching header children.","Verify which properties the control supports before building search conditions."],"exampleFix":"// before\nvar cond = new PropertyCondition(ValuePattern.ValueProperty, \"x\"); // unsupported for find\nvar header = presenterPeer.FindFirst(TreeScope.Children, cond);\n\n// after\nvar cond = new PropertyCondition(AutomationElement.NameProperty, \"Name\");\nvar header = presenterPeer.FindFirst(TreeScope.Children, cond);","handlingStrategy":"try-catch","validationCode":"// Build find conditions only from properties the control supports (e.g. AutomationId, Name).","typeGuard":null,"tryCatchPattern":"try { peer.FindFirst(TreeScope.Children, condition); } catch (ArgumentException) { /* retry with supported/empty property condition */ }","preventionTips":["Use supported property ids in find conditions","Prefer AutomationId/Name conditions over Value/selection properties","Catch ArgumentException from FindFirst/FindAll and retry without the condition"],"tags":["wpf","automation","datagrid","find","invalid-argument"],"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-21T21:30:21.729Z"}