dotnet/wpf · error · ArgumentException
SR.PropertyNotSupported
Error message
SR.PropertyNotSupported
What it means
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.)
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.
Example fix
// before var cond = new PropertyCondition(ValuePattern.ValueProperty, "x"); // unsupported for find var header = presenterPeer.FindFirst(TreeScope.Children, cond); // after var cond = new PropertyCondition(AutomationElement.NameProperty, "Name"); var header = presenterPeer.FindFirst(TreeScope.Children, cond);
Defensive patterns
Strategy: try-catch
Validate before calling
// Build find conditions only from properties the control supports (e.g. AutomationId, Name).
Try / catch
try { peer.FindFirst(TreeScope.Children, condition); } catch (ArgumentException) { /* retry with supported/empty property condition */ } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- SR.DataGrid_AutomationInvokeFailed
- SR.DataGrid_CannotSelectCell
- SR.DataGrid_ColumnIsReadOnly
- SR.DataGrid_InvalidColumnReuse
- SR.DataGridColumnHeaderItemAutomationPeer_Unresizable
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/52bf40c074b3eae0.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/DataGridColumnHeadersPresenterAutomationPeer.cs:158
///<summary>
/// Find Childrend Peers based on Automation Properties.
/// Used to enable virtualization with automation.
///
/// GetChildrenCore and FindItemByProperty are almost straight copies of the
/// ItemControlAutomationPeer code; however since DataGridColumHeaderPresenter
/// returns the Column.Header's as the items some specialized code was needed to
/// create and store peers.
///</summary>
IRawElementProviderSimple IItemContainerProvider.FindItemByProperty(IRawElementProviderSimple startAfter, int propertyId, object value)
{
ResetChildrenCache();
// Checks if propertyId is valid else throws ArgumentException to notify it as invalid argument is being passed
if (propertyId != 0)
{
if (!IsPropertySupportedByControlForFindItem(propertyId))
{
throw new ArgumentException(SR.PropertyNotSupported);
}
}
ItemsControl owner = (ItemsControl)Owner;
IList items = null;
if (owner != null)
items = OwningDataGrid.Columns;
if (items != null && items.Count > 0)
{
DataGridColumnHeaderItemAutomationPeer startAfterItem = null;
if (startAfter != null)
{
// get the peer corresponding to this provider
startAfterItem = PeerFromProvider(startAfter) as DataGridColumnHeaderItemAutomationPeer;
if (startAfterItem == null)
return null;View on GitHub (pinned to 81131a70a4)