WinForms: An element of the given ControlType does not support the UIA Text pattern

This article is referenced directly by Microsoft Accessibility Insights for Windows. Microsoft Accessibility Insights for Windows can help spotlight many accessibility issues in UI, and guide you to the relevant UI framework-specific code sample to help you resolve the issue. Learn more about Microsoft Accessibility Insights for Windows.

Error message

This issue can cause the following error message in Accessibility Insights for Windows: An element of the given ControlType must support the Text pattern.

How to investigate

This issue is tracked on GitHub at winforms#1588. It has been fixed in .NET Framework 4.8.1 and in .NET Core 3.1. If your application is already targeting a fixed version, then you may have a problem in your code.

Possible workarounds

To take advantage of the fixed behavior, you need to enable it. You can do this in two ways:

  1. Target a fixed version of .NET or .NET Framework
  2. If your application uses .NET Framework but targets a version older than 4.8.1, you can add the following AppContextSwitchOverrides to your app.config file to enable the new behavior on machines where .NET Framework 4.8.1 is installed:
  <runtime>
    <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;Switch.UseLegacyAccessibilityFeatures.3=false;Switch.UseLegacyAccessibilityFeatures.4=false;Switch.UseLegacyAccessibilityFeatures.5=false;" />
  </runtime>