winforms-accessibility-changes-48.md

August 20, 2019 ยท View on GitHub

Accessibility improvements in Windows Forms controls for .NET 4.8

Scope

Major

Version Introduced

4.8

Source Analyzer Status

NotPlanned

Change Description

The Windows Forms Framework is continuing to improve how it works with accessibility technologies to better support Windows Forms customers. These include the following changes:

  • Changes to improve display during High Contrast mode.

  • Changes to interaction with Narrator.

  • Changes in the Accessible hierarchy (improving navigation through the UI Automation tree).

  • Quirked

  • Build-time break

How to opt in or out of these changes

In order for the application to benefit from these changes, it must run on the .NET Framework 4.8. The application can opt in into these changes in either of the following ways:

  • It is recompiled to target the .NET Framework 4.8. These accessibility changes are enabled by default on Windows Forms applications that target the .NET Framework 4.8.
  • It targets the .NET Framework 4.7.2 or earlier version and opts out of the legacy accessibility behaviors by adding the following AppContext switch to the <runtime> section of the app config file and setting it to false, as the following example shows.
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
      </startup>
      <runtime>
        <!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true|false;key2=true|false  -->
        <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;Switch.UseLegacyAccessibilityFeatures.3=false" />
      </runtime>
    </configuration>

Note that to opt in to the accessibility features added in .NET Framework 4.8, you must also opt in to accessibility features of .NET Framework 4.7.1 and 4.7.2 as well. Applications that target the .NET Framework 4.8 and want to preserve the legacy accessibility behavior can opt in to the use of legacy accessibility features by explicitly setting this AppContext switch to true.

Enabling the keyboard ToolTip invocation support requires adding the Switch.System.Windows.Forms.UseLegacyToolTipDisplay=false line to the AppContextSwitchOverrides value:

`<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;Switch.UseLegacyAccessibilityFeatures.3=false;Switch.System.Windows.Forms.UseLegacyToolTipDisplay=false" />`

Note that enabling this feature requires opting in to the aforementioned accessibility features of .NET Framework 4.7.1 - 4.8. Also, if any of the accessibility features are not opted in but the tooltip display feature is opted in, a runtime xref:System.NotSupportedException will be thrown on the first access to these features. The exception message indicates that keyboard ToolTips require accessibility improvements of level 3 to be enabled.

Use of OS-defined colors in High Contrast themes

  • Improved high-contrast themes.

Improved Narrator support

Improved CheckedListBox Accessibility support

Improved ComboBox Accessibility support

Improved DataGridView Accessibility support

Improved LinkLabel Accessibility support

Improved ProgressBar Accessibility support

  • Enabled UI Automation support for the xref:System.Windows.Forms.ProgressBar control with the ability to use UI Automation notifications and other UI Automation features. Developers are now able to use UI Automation notifications which Narrator can announce to indicate progress.

For an overview of UI automation events overview, including UI automation notification events, see the UI Automation Events Overview.

Improved PropertyGrid Accessibility support

  • Enabled UI Automation support for the xref:System.Windows.Forms.PropertyGrid control, with the ability to use UI Automation notifications and other UI Automation features.
  • The UI Automation element which corresponds to the currently edited property is now a child of the corresponding property item UI Automation element.
  • The UI Automation property item element is now a child of the corresponding category element if the parent xref:System.Windows.Forms.PropertyGrid control is set to category view.

Improved ToolStrip support

Improved Visual cues

Note: UI automation support is enabled for controls in runtime but is not used in design time. For an overview of UI automation, see the UI Automation Overview.

Invoking controls' ToolTips with a keyboard

  • Control tooltip can now be invoked by focusing the control with keyboard. This feature needs to be enabled explicitly for the application (see section "How to opt in or out of these changes")

Showing controls' ToolTips in multiple monitors

  • ToolTip appearance in multi-monitor environments with different DPI scales is correct now and adapted to not truncate the begginnig of text in case the ToolTip text is too long.

Affected APIs

Category

Windows Forms