dotnet/wpf · error · ArgumentException
SR.UnsupportedProperty
Error message
SR.UnsupportedProperty
What it means
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.
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
Example fix
// before var prop = AutomationProperty.LookupById(99999); // unknown/custom pattern.FindItemByProperty(null, prop, "x"); // ArgumentException // after pattern.FindItemByProperty(null, AutomationElement.NameProperty, "x");
Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<AutomationProperty> Known = new(){ AutomationElement.NameProperty, AutomationElement.AutomationIdProperty, AutomationElement.ControlTypeProperty /* ... */ };
if (!Known.Contains(prop)) throw new InvalidOperationException("Unknown property for FindItemByProperty"); Type guard
bool IsKnownUiaProperty(AutomationProperty p) => p == AutomationElement.NameProperty || p == AutomationElement.AutomationIdProperty || p == AutomationElement.ControlTypeProperty;
Try / catch
try { pattern.FindItemByProperty(null, prop, value); } catch (ArgumentException ex) { /* log unsupported property, fall back to enumeration */ } Prevention
- Only use properties from AutomationElement*/pattern identifier classes
- Avoid hand-built AutomationProperty instances
- Prefer AutomationElement.NotSupported value to match all items
When it happens
Trigger: Passing a custom AutomationProperty, a property from another provider framework, or a null/unknown identifier to FindItemByProperty(property, value).
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- SR.Format(SR.PropertyConditionIncorrectType…
- SR.UnsupportedProperty
- E_INVALIDARG
- name
- SR.BeginEndTextContainerMismatch
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/752233f7824f87fa.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/ItemContainerPattern.cs:129
return wrappedElement;
}
#endregion Public Methods
//------------------------------------------------------
//
// Private Methods
//
//------------------------------------------------------
#region Private Methods
private object PropertyValueValidateAndMap(AutomationProperty property, object value)
{
AutomationPropertyInfo info;
if (!Schema.GetPropertyInfo(property, out info))
{
throw new ArgumentException(SR.UnsupportedProperty);
}
// Check type is appropriate: NotSupported is allowed against any property,
// null is allowed for any reference type (ie not for value types), otherwise
// type must be assignable from expected type.
Type expectedType = info.Type;
if (value != AutomationElement.NotSupported &&
((value == null && expectedType.IsValueType)
|| (value != null && !expectedType.IsAssignableFrom(value.GetType()))))
{
throw new ArgumentException(SR.Format(SR.PropertyConditionIncorrectType, property.ProgrammaticName, expectedType.Name));
}
// Some types are handled differently in managed vs unmanaged - handle those here...
if (value is AutomationElement)
{
// If this is a comparison against a Raw/LogicalElement,
// save the runtime ID instead of the element so that weView on GitHub (pinned to 81131a70a4)