.NET Framework 協助工具的新功能What's new in accessibility in the .NET Framework

.NET Framework 的目標在於讓使用者更容易存取應用程式。The .NET Framework aims at making applications more accessible for your users. 協助工具功能可讓應用程式提供適當的輔助技術使用者體驗。Accessibility features allow an application to provide an appropriate experience for users of Assistive Technology. 從 .NET Framework 4.7.1 開始,.NET Framework 包含大量協助工具改善,可讓開發人員建立無障礙應用程式。Starting with .NET Framework 4.7.1, the .NET Framework includes a large number of accessibility improvements that allow developers to create accessible applications.

協助工具參數Accessibility switches

如果您的應用程式是以 .NET Framework 4.7 或較早版本為目標,但是在 .NET Framework 4.7.1 或更新版本上執行,您可以將其設定為選擇加入協助工具功能。You can configure your app to opt into accessibility features if it targets .NET Framework 4.7 or an earlier version but is running on .NET Framework 4.7.1 or later. 如果您的應用程式是以 .NET Framework 4.7.1 或更新版本為目標,您也可以將其設定為使用舊版的功能 (且不利用協助工具功能)。You can also configure your app to use legacy features (and not take advantage of accessibility features) if it targets .NET Framework 4.7.1 or later. 包含協助工具功能的每個 .NET Framework 版本都有版本特定的協助工具參數,您可以新增到應用程式組態檔 <runtime> 區段中的 <AppContextSwitchOverrides> 項目。Each version of the .NET Framework that includes accessibility features has a version-specific accessibility switch, which you add to the <AppContextSwitchOverrides> element in the <runtime> section of the application's configuration file. 以下是支援的參數:The following are the supported switches:

版本Version 參數Switch
.NET Framework 4.7.1.NET Framework 4.7.1 "Switch.UseLegacyAccessibilityFeatures""Switch.UseLegacyAccessibilityFeatures"
.NET Framework 4.7.2.NET Framework 4.7.2 "Switch.UseLegacyAccessibilityFeatures.2""Switch.UseLegacyAccessibilityFeatures.2"
.NET Framework 4.8.NET Framework 4.8 "Switch.UseLegacyAccessibilityFeatures.3""Switch.UseLegacyAccessibilityFeatures.3"

利用協助工具增強功能Taking advantage of accessibility enhancements

針對以 .NET Framework 4.7.1 或更新版本為目標的應用程式,預設會啟用新的協助工具功能。The new accessibility features are enabled by default for applications that target .NET Framework 4.7.1 or later. 此外,如果應用程式是以舊版 .NET Framework 為目標但在 .NET Framework 4.7.1 或更新版本上執行,您可以新增參數至應用程式組態檔 <runtime> 區段中的 <AppContextSwitchOverrides> 項目,並將其值設定為 false,使其退出舊版協助工具行為 (進而利用協助工具改善)。In addition, applications that target an earlier version of the .NET Framework but are running on .NET Framework 4.7.1 or later can opt out of legacy accessibility behaviors (and thereby take advantage of accessibility improvements) by adding switches to the <AppContextSwitchOverrides> element in the <runtime> section of the application's configuration file and setting their value to false. 下列顯示如何選擇加入 .NET Framework 4.7.1 中引進的協助工具增強功能:The following shows how to opt in to accessibility enhancements introduced in .NET Framework 4.7.1:

<runtime>
    <!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true|false;key2=true|false  -->
    <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false" />
</runtime>

如果您選擇加入 .NET Framework 較新版本中的協助工具功能,您必須同時明確加入來自舊版 .NET Framework 的功能。If you choose to opt in to accessibility features in a later version of the .NET Framework, you must also explicitly opt in to the features from earlier versions of the .NET Framework. 若要將應用程式設定為同時利用 .NET Framework 4.7.1 和 4.7.2 的協助工具改善,您必須使用下列 <AppContextSwitchOverrides> 項目:Configuring your app to take advantage of accessibility improvements in both .NET Framework 4.7.1 and 4.7.2 requires the following <AppContextSwitchOverrides> element:

<runtime>
    <!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true|false;key2=true|false  -->
    <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false" />
</runtime>

若要將應用程式設定為利用 .NET Framework 4.7.1、4.7.2 和 4.8 的協助工具改善,您必須使用下列 <AppContextSwitchOverrides> 項目:Configuring your app to take advantage of accessibility improvements in .NET Framework 4.7.1, 4.7.2, and 4.8 requires the following <AppContextSwitchOverrides> element:

<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>

還原舊版行為Restoring legacy behavior

以從 4.7.1 開始的 .NET Framework 版本為目標的應用程式,可以停用協助工具功能,方法是新增參數至應用程式組態檔之 <runtime> 區段中的 <AppContextSwitchOverrides> 項目,並將其值設定為 trueApplications that target versions of the .NET Framework starting with 4.7.1 can disable accessibility features by adding switches to the <AppContextSwitchOverrides> element in the <runtime> section of the application's configuration file and setting their value to true. 例如,下列組態會選擇退出 .NET Framework 4.7.2 中引進的協助工具功能:For example, the following configuration opts out of accessibility features introduced in .NET Framework 4.7.2:

<runtime>
    <!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true|false;key2=true|false  -->
    <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures.2=true" />
</runtime>

.NET Framework 4.8 協助工具的新功能What's new in accessibility in .NET Framework 4.8

.NET Framework 4.8 包含下列領域的新協助工具功能:.NET Framework 4.8 includes new accessibility features in the following areas:

Windows FormsWindows Forms

在 .NET Framework 4.8 中,Windows Forms 已新增對許多常用控制項的 LiveRegions 和通知事件支援。In .NET Framework 4.8, Windows Forms adds support for LiveRegions and Notification Events to many commonly used controls. 它也新增當使用者利用鍵盤巡覽至控制項時的工具提示支援。It also adds support for ToolTips when a user navigates to a control by using the keyboard.

標籤與 StatusStrips 中的 UIA LiveRegions 支援UIA LiveRegions Support in Labels and StatusStrips

UIA LiveRegions 可讓應用程式開發人員將控制項中的文字變更 (位於使用者正在處理的位置以外) 通知螢幕助讀程式。UIA LiveRegions allow application developers to notify screen readers of a text change in a control that is located apart from the location where the user is working. 例如,對於顯示連線狀態的 StatusStrip 控制項,這非常有用。This is useful, for example, for a StatusStrip control that shows a connection status. 當連線中斷且狀態變更時,開發人員可能需要通知螢幕助讀程式。If the connection is dropped and the status changes, the developer might want to notify the screen reader.

從 .NET Framework 4.8 開始,Windows Forms 即針對 LabelStatusStrip 這兩個控制項實作 UIA LiveRegions。Starting with .NET Framework 4.8, Windows Forms implements UIA LiveRegions for both the Label and StatusStrip controls. 例如,下列程式碼會在名為 label1Label 控制項中使用 LiveRegion:For example, the following code uses the LiveRegion in a Label control named label1:

public Form1()
{
   InitializeComponent();
   label1.AutomationLiveSetting = AutomationLiveSetting.Polite;
}

…
Label1.Text = “Ready!”;

不論使用者與應用程式互動的位置為何,朗讀程式均會播報「就緒」。Narrator announces “Ready” regardless of where the user is interacting with the application.

您也可以將您的 UserControl 實作為 LiveRegion:You can also implement your UserControl as a LiveRegion:

using System;
using System.Windows.Forms;
using System.Windows.Forms.Automation;

namespace WindowsFormsApplication
{
   public partial class UserControl1 : UserControl, IAutomationLiveRegion
   {
      public UserControl1()
      {
         InitializeComponent();
      }

      public AutomationLiveSetting AutomationLiveSetting { get; set; }
      private AutomationLiveSetting IAutomationLiveRegion.GetLiveSetting()
      {
         return this.AutomationLiveSetting;
      }

      protected override void OnTextChanged(EventArgs e)
      {
         base.OnTextChanged(e);
         AutomationNotifications.UiaRaiseLiveRegionChangedEvent(this.AccessibilityObject);
      }
   }
}

UIA 通知事件UIA notification events

Windows 10 Fall Creators Update 中引進了 UIA 通知事件,其可讓您的應用程式引發 UIA 事件,並讓朗讀程式只依據您提供的事件文字來播報,而不需要在 UI 中具備對應的控制項。The UIA Notification event, introduced in Windows 10 Fall Creators Update, allows your app to raise a UIA event, which leads to Narrator simply making an announcement based on text you supply with the event, without the need to have a corresponding control in the UI. 在某些情況下,這是大幅改善應用程式協助工具的直接方法。In some scenarios, this is a straightforward way to dramatically improve the accessibility of your app. 它也可以用來通知可能需要長時間處理的程序進度。In can also be useful to notify of the progress of some process that may take a long time. 如需 UIA 通知事件的詳細資訊,請參閱 Can your desktop app leverage the new UI Notification event? (傳統型應用程式可以利用新的 UI 通知事件嗎?)For more information about UIA Notification Events, see Can your desktop app leverage the new UI Notification event?.

下列範例會引發通知事件The following example raises the Notification event:

MethodInfo raiseMethod = typeof(AccessibleObject).GetMethod("RaiseAutomationNotification");
if (raiseMethod != null) {
   raiseMethod.Invoke(progressBar1.AccessibilityObject, new object[3] {/*Other*/ 4, /*All*/ 2, "The progress is 50%." });
}

鍵盤存取的工具提示ToolTips on keyboard access

在目標為 .NET Framework 4.7.2 和更早版本的應用程式中,只有將滑鼠指標移到控制項中才會觸發跳出該控制項的工具提示In applications that target .NET Framework 4.7.2 and earlier versions, a control tooltip can only be triggered to pop up by moving a mouse pointer into the control. 從 .NET Framework 4.8 開始,不論有無輔助按鍵,鍵盤使用者均可使用 Tab 鍵或方向鍵把焦點放在控制項上,藉此觸發控制項的工具提示。Starting with .NET Framework 4.8, a keyboard user can trigger a control’s tooltip by focusing the control using a Tab key or arrow keys with or without modifier keys. 這個特定協助工具增強功能需要額外的 AppContext 參數This particular accessibility enhancement requires an additional AppContext switch:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <startup>
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
   </startup>
   <runtime>
      <!-- AppContextSwitchOverrides values are in the form of 'key1=true|false;key2=true|false  -->
      <!-- Please note that disabling Switch.UseLegacyAccessibilityFeatures, Switch.UseLegacyAccessibilityFeatures.2 and Switch.UseLegacyAccessibilityFeatures.3 is required to disable Switch.System.Windows.Forms.UseLegacyToolTipDisplay -->
      <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;Switch.UseLegacyAccessibilityFeatures.3=false;Switch.System.Windows.Forms.UseLegacyToolTipDisplay=false"/>
   </runtime>
</configuration>

下圖顯示當使用者以鍵盤選取按鈕時的工具提示。The following figure shows the tooltip when the user has selected a button with the keyboard.

當使用者以鍵盤巡覽至按鈕時的工具提示

Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF)

從 .NET Framework 4.8 開始,WPF 包含許多協助工具改善。Starting with .NET Framework 4.8, WPF includes a number of accessibility improvements.

螢幕朗讀程式不再播報含摺疊或隱藏可見度的項目Screen narrators no longer announce elements with Collapsed or Hidden visibility

螢幕朗讀程式不會再播報含摺疊或隱藏可見度的項目。Elements with collapsed or hidden visibility are no longer announced by screen reader. 如果使用者介面包含的項目可見度為 Visibility.CollapsedVisibility.Hidden,則螢幕助讀程式向使用者播報時可能會表達錯誤。User interfaces that contain elements with a Visibility of Visibility.Collapsed or Visibility.Hidden can be misrepresented by screen readers if they are announced to the user. 從 .NET Framework 4.8 開始,WPF 的 UIAutomation 樹狀結構控制項檢視中不會再包含摺疊或隱藏項目,因此螢幕助讀程式即無法再播報這些項目。Starting with .NET Framework 4.8, WPF no longer includes collapsed or hidden elements in the Control View of the UIAutomation tree, so the screen readers can no longer announce these elements.

搭配使用非 Adorner 文字選取範圍的 SelectionTextBrush 屬性SelectionTextBrush property for use with non-Adorner based text selection

在 .NET Framework 4.7.2 中,WPF 新增了繪製 TextBoxPasswordBox 文字選取範圍的功能,而不需使用 Adorner 圖層。In the .NET Framework 4.7.2, WPF added the ability to draw TextBox and PasswordBox text selection without using the Adorner layer. 在此案例中,選取文字的前景色彩取決於 SystemColors.HighlightTextBrushThe foreground color of the selected text in this scenario was dictated by SystemColors.HighlightTextBrush.

.NET Framework 4.8 新增 SelectionTextBrush 屬性,可讓開發人員在使用非 Adorner 文字選取範圍時,針對選取的文字選取特定筆刷。.NET Framework 4.8 adds a new property, SelectionTextBrush, that allows developers to select the specific brush for the selected text when using non-Adorner based text selection. 此屬性僅適用於 WPF 應用程式 (已啟用非 Adorner 文字選取範圍) 中 TextBoxBase 衍生的控制項和 PasswordBox 控制項。This property works only on TextBoxBase-derived controls and the PasswordBox control in WPF applications with non-Adorner-based text selection enabled. 此屬性不適用於 RichTextBox 控制項。It does not work on the RichTextBox control. 如果未啟用非 Adorner 文字選取範圍,則會忽略這個屬性。If non-Adorner-based text selection is not enabled, this property is ignored.

若要使用這個屬性,只要將它新增至您的 XAML 程式碼,並使用適當的筆刷或繫結即可。To use this property, simply add it to your XAML code and use the appropriate brush or binding. 產生的文字選取範圍看起來像這樣:The resulting text selection looks like this:

當使用者以鍵盤巡覽至按鈕時的工具提示

您可以結合 SelectionBrushSelectionTextBrush 屬性的用法,視需要產生任何背景和前景色彩的組合。You can combine the use of the SelectionBrush and SelectionTextBrush properties to generate any background and foreground color combination that you deem appropriate.

支援 UIAutomation ControllerFor 屬性Support for the UIAutomation ControllerFor property

UIAutomation 的 ControllerFor 屬性會傳回自動化項目的陣列,而這些項目是由支援此屬性的自動化項目所操作。UIAutomation’s ControllerFor property returns an array of automation elements that are manipulated by the automation element that supports this property. 此屬性通常用於自動建議的協助工具。This property is commonly used for Auto-suggest accessibility. 當自動化項目會影響應用程式 UI 或桌面的一或多個區段時,請使用 ControllerForControllerFor is used when an automation element affects one or more segments of the application UI or the desktop. 否則,您很難將控制作業的影響與 UI 項目建立關聯。Otherwise, it is hard to associate the impact of the control operation with UI elements. 這項功能讓控制項能夠提供 ControllerFor 屬性值。This feature adds the ability for controls to provide a value for the ControllerFor property.

.NET Framework 4.8 新增新的虛擬方法 GetControlledPeersCore().NET Framework 4.8 adds a new virtual method, GetControlledPeersCore(). 若要提供 ControllerFor 屬性值,只要覆寫這個方法,並傳回控制項 (由此 AutomationPeer 操作) 的 List<AutomationPeer> 即可:To provide a value for the ControllerFor property, simply override this method and return a List<AutomationPeer> for the controls being manipulated by this AutomationPeer:

public class AutoSuggestTextBox: TextBox
{
   protected override AutomationPeer OnCreateAutomationPeer()
   {
      return new AutoSuggestTextBoxAutomationPeer(this);
   }

   public ListBox SuggestionListBox;
}

internal class AutoSuggestTextBoxAutomationPeer : TextBoxAutomationPeer
{
   public AutoSuggestTextBoxAutomationPeer(AutoSuggestTextBox owner) : base(owner)
   {
   }

   protected override List<AutomationPeer> GetControlledPeersCore()
   {
      List<AutomationPeer> controlledPeers = new List<AutomationPeer>();
      AutoSuggestTextBox owner = Owner as AutoSuggestTextBox;
      controlledPeers.Add(UIElementAutomationPeer.CreatePeerForElement(owner.SuggestionListBox));
      return controlledPeers;
   }
}

鍵盤存取的工具提示Tooltips on keyboard access

在 .NET Framework 4.7.2 和更早版本中,只有當使用者將滑鼠游標停留在控制項上方時會顯示工具提示。In .NET Framework 4.7.2 and earlier versions, tooltips display only when the user hovers the mouse cursor over a control. 在 .NET Framework 4.8 中,工具提示也會在鍵盤焦點上顯示,以及透過鍵盤快速鍵顯示。In .NET Framework 4.8, tooltips also display on keyboard focus, as well as via a keyboard shortcut.

若要啟用這項功能,應用程式需要以 .NET Framework 4.8 為目標,或使用 Switch.UseLegacyAccessibilityFeatures.3Switch.UseLegacyToolTipDisplay AppContext 參數選擇加入。To enable this feature, an application needs to target .NET Framework 4.8 or opt-in by using the Switch.UseLegacyAccessibilityFeatures.3 and Switch.UseLegacyToolTipDisplay AppContext switches. 下列是範例應用程式組態檔:The following is a sample application configuration file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <startup>
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
   </startup>
   <runtime>
      <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;Switch.UseLegacyAccessibilityFeatures.3=false;Switch.UseLegacyToolTipDisplay=false" />
   </runtime>
</configuration>

啟用之後,一旦控制項取得鍵盤焦點時,所有包含工具提示的控制項會都顯示工具提示。Once enabled, all controls that contain a tooltip display it once the control receives keyboard focus. 工具提示可能會隨著時間或鍵盤焦點變更而關閉。The tooltip can be dismissed over time or when the keyboard focus changes. 使用者也可以使用新的鍵盤快速鍵 Ctrl + Shift + F10,手動關閉工具提示。Users can also dismiss the tooltip manually by using a new keyboard shortcut, Ctrl + Shift + F10. 工具提示關閉之後,您可以使用相同的鍵盤快速鍵使其再次顯示。Once the tooltip has been dismissed it can be displayed again by using the same keyboard shortcut.

注意

Ribbon 控制項上的功能區工具提示不會顯示在鍵盤焦點上;而只能透過鍵盤快速鍵顯示。Ribbon tooltips on Ribbon controls won’t show on keyboard focus; they only show via the keyboard shortcut.

新增支援 SizeOfSet 和 PositionInSet UIAutomation 屬性Added Support for SizeOfSet and PositionInSet UIAutomation properties

Windows 10 引進 SizeOfSetPositionInSet 這兩個新的 UIAutomation 屬性;應用程式會使用該屬性來描述集合中的項目計數。Windows 10 introduced two new UIAutomation properties, SizeOfSet and PositionInSet, which are used by applications to describe the count of items in a set. UIAutomation 用戶端應用程式 (例如螢幕助讀程式) 可以查詢應用程式的這些屬性,並播報應用程式 UI 的精確呈現。UIAutomation client applications such as screen readers can then query an application for these properties and announce an accurate representation of the application’s UI.

從 .NET Framework 4.8 開始,WPF 會將這兩個屬性公開至 WPF 應用程式中的 UIAutomation。Starting with .NET Framework 4.8, WPF exposes these two properties to UIAutomation in WPF applications. 這可由下列兩種方法來完成:This can be accomplished in two ways:

  • 藉由使用相依性屬性。By using dependency properties.

    WPF 新增 AutomationProperties.SizeOfSetAutomationProperties.PositionInSet 這兩個新的相依性屬性。WPF adds two new dependency properties, AutomationProperties.SizeOfSet and AutomationProperties.PositionInSet. 開發人員可以使用 XAML 來設定其值:A developer can use XAML to set their values:

    <Button AutomationProperties.SizeOfSet="3"
      AutomationProperties.PositionInSet="1">Button 1</Button>
    
    <Button AutomationProperties.SizeOfSet="3"
      AutomationProperties.PositionInSet="2">Button 2</Button>
    
    <Button AutomationProperties.SizeOfSet="3"
      AutomationProperties.PositionInSet="3">Button 3</Button>
    
  • 藉由覆寫 AutomationPeer 虛擬方法。By overriding AutomationPeer virtual methods.

    AutomationPeer 類別已新增 GetSizeOfSetCore()GetPositionInSetCore() 虛擬方法。The GetSizeOfSetCore() and GetPositionInSetCore() virtual methods been added to the AutomationPeer class. 開發人員可以覆寫這些方法來提供 SizeOfSetPositionInSet 的值,如下列範例所示:A developer can provide values for SizeOfSet and PositionInSet by overriding these methods, as shown in the following example:

    public class MyButtonAutomationPeer : ButtonAutomationPeer
    {
      protected override int GetSizeOfSetCore()
      {
          // Call into your own logic to provide a value for SizeOfSet
          return CalculateSizeOfSet();
      }
    
      protected override int GetPositionInSetCore()
      {
          // Call into your own logic to provide a value for PositionInSet
          return CalculatePositionInSet();
      }
    }
    

此外,ItemsControl 執行個體中的項目可自動提供這些屬性值,而不需要開發人員的額外動作。In addition, items in ItemsControl instances provide a value for these properties automatically without additional action from the developer. 如果 ItemsControl 是分組形式,即會以各組來表示群組的集合,並將每個群組計算為個別的一組,而該群組內每個項目均提供其在該群組內的位置及群組大小。If an ItemsControl is grouped, the collection of groups is represented as a set, and each group is counted as a separate set, with each item inside that group providing its position inside that group as well as the size of the group. 虛擬化不會影響自動值。Automatic values are not affected by virtualization. 即使某個項目未具現化,系統仍會將其計入集合的總大小,並會影響其同層級項目集合的位置。Even if an item is not realized, it is still counted toward the total size of the set and affects the position in the set of its sibling items.

只有在應用程式的目標為 .NET Framework 4.8 時,系統才會提供自動值。Automatic values are only provided if the application targets .NET Framework 4.8. 若是以舊版 .NET Framework 為目標的應用程式,您可以設定 Switch.UseLegacyAccessibilityFeatures.3 AppContext 參數,如下列 App.config 檔案中所示:For applications that target an earlier version of the .NET Framework, you can set the Switch.UseLegacyAccessibilityFeatures.3 AppContext switch, as shown in the following App.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <startup>
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
   </startup>
   <runtime>
      <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;Switch.UseLegacyAccessibilityFeatures.3=false" />
   </runtime>
</configuration>

Windows Workflow Foundation (WF) 工作流程設計工具Windows Workflow Foundation (WF) workflow designer

工作流程設計工具包括下列各項 .NET Framework 4.8 的變更:The workflow designer includes the following changes in .NET Framework 4.8:

  • 使用朗讀程式的使用者會看到 FlowSwitch 案例標籤方面的改善。Users using Narrator will see improvements in FlowSwitch case labels.

  • 使用朗讀程式的使用者會看到按鈕描述方面的改善。Users using Narrator will see improvements in button descriptions.

  • 選擇高對比佈景主題之使用者會看到工作流程設計工具和其控制項在可見度方面的改善,例如項目之間的更佳對比比例,以及用於焦點項目的更明顯選取方塊。Users who choose High Contrast themes will see improvements in the visibility of the Workflow Designer and its controls, like better contrast ratios between elements and more noticeable selection boxes used for focus elements.

如果應用程式是以 .NET Framework 4.7.2 或更早的版本為目標,您可以將應用程式組態檔中的 Switch.UseLegacyAccessibilityFeatures.3 AppContext 參數 設為 false 來選擇加入這些變更。If your application targets .NET Framework 4.7.2 or an earlier version, you can opt into these changes by setting the Switch.UseLegacyAccessibilityFeatures.3 AppContext switch to false in your application configuration file. 如需詳細資訊,請參閱本文的利用協助工具增強功能一節。For more information, see the Taking advantage of accessibility enhancements section in this article.

.NET Framework 4.7.2 協助工具的新功能What's new in accessibility in .NET Framework 4.7.2

.NET Framework 4.7.2 包含下列領域的新協助工具功能:.NET Framework 4.7.2 includes new accessibility features in the following areas:

Windows FormsWindows Forms

高對比佈景主題中的作業系統定義色彩OS-defined colors in High Contrast themes

從 .NET Framework 4.7.2 開始,Windows Forms 在高對比佈景主題中使用作業系統所定義的色彩。Starting with .NET Framework 4.7.2, Windows Forms uses colors defined by the operating system in High Contrast themes. 這會影響下列控制項:This affects the following controls:

朗讀程式增強功能Narrator improvements

從 .NET Framework 4.7.2 開始,朗讀程式支援的增強功能如下:Starting with .NET Framework 4.7.2, Narrator support is enhanced as follows:

DataGridView 改善DataGridView improvements

從 .NET Framework 4.7.2 開始,DataGridView 控制項已經引進下列協助工具改善:Starting with .NET Framework 4.7.2, the DataGridView control has introduced the following accessibility improvements:

改善的視覺提示Improved visual cues

已改進屬性方格支援Improved Property Grid Support

改善的鍵盤導覽Improved keyboard navigation

Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF)

CheckBox 和 RadioButton 控制項的變更Changes to the CheckBox and RadioButton controls

在 .NET Framework 4.7.1 和舊版的傳統和高對比佈景主題中,WPF CheckBoxRadioButton 控制項的焦點視覺效果不一致且不正確。In .NET Framework 4.7.1 and earlier versions, the WPF CheckBox and RadioButton controls have inconsistent and, in Classic and High Contrast themes, incorrect focus visuals. 當控制項沒有任何內容集時,會發生上述問題。These issues occur in cases where the controls do not have any content set. 這可能會讓人混淆佈景主題之間的轉換,也看不清楚焦點視覺效果。This can make the transition between themes confusing and the focus visual hard to see.

現在,.NET Framework 4.7.2 的這些視覺效果在各佈景主題之間會更一致;在傳統和高對比佈景主題中也可以看得更清楚。In .NET Framework 4.7.2, these visuals are now more consistent across themes and more easily visible in Classic and High Contrast themes.

裝載於 WPF 應用程式的 WinForms 控制項WinForms controls hosted in a WPF application

針對 .NET Framework 4.7.1 和舊版中裝載於 WPF 應用程式的 WinForms 控制項,如果 WinForms 層的第一個或最後一個控制項是 WPF ElementHost 控制項,則使用者無法按 Tab 鍵移出該 WinForms 層。For WinForms control hosted in a WPF application in .NET Framework 4.7.1 and earlier versions, users couldn't tab out of the WinForms layer if the first or last control in that layer is the WPF ElementHost control. 在 .NET Framework 4.7.2 中,使用者現在能按 Tab 鍵移出 WinForms 層。In .NET Framework 4.7.2, users are now able to tab out of the WinForms layer.

不過,依賴焦點絕不會逸出 WinForms 層的自動化應用程式可能不再如預期運作。However, automated applications that rely on focus never escaping the WinForms layer may no longer work as expected.

.NET Framework 4.7.1 協助工具的新功能What's new in accessibility in .NET Framework 4.7.1

.NET Framework 4.7.1 包含下列領域的新協助工具功能:.NET Framework 4.7.1 includes new accessibility features in the following areas:

Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF)

螢幕助讀程式改善Screen reader improvements

如果啟用協助工具改善,則 .NET Framework 4.7.1 會包含下列影響螢幕助讀程式的增強功能:If accessibility improvements are enabled, .NET Framework 4.7.1 includes the following enhancements that affect screen readers:

  • 在 .NET Framework 4.7 和舊版本中,螢幕助讀程式會將 Expander 控制項宣告為按鈕。In .NET Framework 4.7 and earlier versions, Expander controls were announced by screen readers as buttons. 從 .NET Framework 4.7.1 開始,螢幕助讀程式已將它們正確地宣告為可展開/可摺疊的群組。Starting with .NET Framework 4.7.1, they are correctly announced as expandable/collapsible groups.

  • 在 .NET Framework 4.7 和舊版本中,螢幕助讀程式會將 DataGridCell 控制項宣告為「自訂」。In .NET Framework 4.7 and earlier versions, DataGridCell controls were announced by screen readers as “custom.” 從 .NET Framework 4.7.1 開始,螢幕助讀程式現在已將它們正確地宣告為資料格儲存格 (當地語系化)。Starting with .NET Framework 4.7.1, they are now correctly announced as data grid cell (localized).

  • 從 .NET Framework 4.7.1 開始,螢幕助讀程式會宣告可編輯 ComboBox 的名稱。Starting with .NET Framework 4.7.1, screen readers announce the name of an editable ComboBox.

  • 在 .NET Framework 4.7 和舊版本中,螢幕助讀程式會將 PasswordBox 控制項宣告為「檢視中沒有項目」或具有不正確的行為。In .NET Framework 4.7 and earlier versions, PasswordBox controls were announced as “no item in view” or had otherwise incorrect behavior. 從 .NET Framework 4.7.1 開始已修正此問題。This issue is fixed starting with .NET Framework 4.7.1.

UIAutomation LiveRegion 支援UIAutomation LiveRegion support

朗讀程式這類螢幕助讀程式可協助人員讀取應用程式 UI 內容,通常是透過具有焦點之 UI 內容的文字轉換語音輸出。Screen readers such as Narrator help people read the UI contents of an application, usually by text-to-speech output of the UI content that has the focus. 不過,如果 UI 項目變更,而且沒有焦點,則使用者可能不會收到通知,並可能遺失重要資訊。However, if a UI element changes and does not have the focus, the user may not be notified and may miss important information. 即時區域的目標在解決這個問題。Live regions aim at solving this problem. 開發人員可以使用它們來通知螢幕助讀程式或任何其他 UIAutomation 用戶端,已對 UI 項目進行重要變更。A developer can use them to inform the screen reader or any other UIAutomation client that an important change has been made to a UI element. 螢幕助讀程式接著可以決定如何和何時通知使用者已進行這項變更。The screen reader can then decide how and when to inform the user of this change.

為了支援即時區域,已將下列 API 新增至 WPF:To support live regions, the following APIs have been added to WPF:

您可以在感興趣的項目上設定 AutomationProperties.LiveSetting 屬性,以建立 LiveRegion,如下列範例所示:You can create a LiveRegion by setting the AutomationProperties.LiveSetting property on the element of interest, as shown in the following example:

<TextBlock Name="myTextBlock" AutomationProperties.LiveSetting="Assertive">announcement</TextBlock>

如果即時區域中的資料變更,而且您需要通知螢幕助讀程式,請明確地引發事件,如下列範例所示。When the data in the live region changes and you need to inform a screen reader, you explicitly raise an event, as shown in the following sample.

var peer = FrameworkElementAutomationPeer.FromElement(myTextBlock);

peer.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
Dim peer = FrameworkElementAutomationPeer.FromElement(myTextBlock)
peer.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged)

高對比High contrast

從 .NET Framework 4.7.1 開始,已對各種 WPF 控制項進行高對比改善。Starting with .NET Framework 4.7.1, improvements in high contrast have been made to various WPF controls. 現在,設定 HighContrast 佈景主題時,可以看到它們。They are now visible when the HighContrast theme is set. 它們包括:These include:

  • Expander 控制項Expander control

    現在會顯示 Expander 控制項的焦點視覺效果。The focus visual for the Expander control is now visible. 現在也會顯示 ComboBoxListBoxRadioButton 控制項的鍵盤視覺效果。The keyboard visuals for ComboBox,ListBox, and RadioButton controls are visible as well. 例如:For example:

    之前:Before: 

    協助工具改善之前的聚焦 Expander 控制項

    之後:After: 

    協助工具改善之後的聚焦 Expander 控制項

  • CheckBoxRadioButton 控制項CheckBox and RadioButton controls

    在高對比佈景主題中選取時,CheckBoxRadioButton 控制項中的文字現在更容易出現。The text in the CheckBox and RadioButton controls is now easier to see when selected in high contrast themes. 例如:For example:

    之前:Before: 

    協助工具改善之前的聚焦高對比選項按鈕

    之後:After: 

    協助工具改善之後的聚焦高對比選項按鈕

  • ComboBox 控制項ComboBox control

    從 .NET Framework 4.7.1 開始,已停用的 ComboBox 控制項框線色彩與已停用的文字色彩相同。Starting with .NET Framework 4.7.1, the border of a disabled ComboBox control is the same color as disabled text. 例如:For example:

    之前:Before: 

    協助工具改善之前的 ComboBox 已停用框線和文字

    之後:After:   

    協助工具改善之後的 ComboBox 已停用框線和文字

    此外,已停用和聚焦按鈕會使用正確的佈景主題色彩。In addition, disabled and focused buttons use the correct theme color.

    之前:Before:

    協助工具改善之前的按鈕佈景主題色彩 

    之後:After: 

    協助工具改善之後的按鈕佈景主題色彩 

    最後,在 .NET Framework 4.7 和舊版本中將 ComboBox 控制項的樣式設定為 Toolbar.ComboBoxStyleKey 會導致無法看到下拉式箭號。Finally, in .NET Framework 4.7 and earlier versions, setting a ComboBox control’s style to Toolbar.ComboBoxStyleKey caused the drop-down arrow to be invisible. 從 .NET Framework 4.7.1 開始已修正此問題。This issue is fixed starting with .NET Framework 4.7.1. 例如:For example:

    之前:Before: 

    協助工具改善之前的 Toolbar.ComboBoxStyleKey 

    之後:After: 

    協助工具改善之後的 Toolbar.ComboBoxStyleKey 

  • DataGrid 控制項DataGrid control

    從 .NET Framework 4.7.1 開始,DataGrid 控制項中的排序指標箭號現在會使用正確佈景主題色彩。Starting with .NET Framework 4.7.1, the sort indicator arrow in DataGrid controls now uses correct theme colors. 例如:For example:

    之前:Before: 

    協助工具改善之前的排序指標箭號 

    之後:After:   

    協助工具改善之後的排序指標箭號 

    此外,在 .NET Framework 4.7 和舊版本的高對比模式中,預設連結樣式會在滑鼠移至上方時變更為不正確的色彩。In addition, in .NET Framework 4.7 and earlier versions, the default link style changed to an incorrect color on mouse over in high contrast modes. 從 .NET Framework 4.7.1 開始已解決此問題。This is resolved starting with .NET Framework 4.7.1. 同樣地,從 .NET Framework 4.7.1 開始,DataGrid 核取方塊資料行會使用鍵盤焦點回饋的預期色彩。Similarly, DataGrid checkbox columns uses the expected colors for keyboard focus feedback starting with .NET Framework 4.7.1.

    之前:Before: 

    協助工具改善之前的 DataGrid 預設連結樣式 

    之後:After:    

    協助工具改善之後的 DataGrid 預設連結樣式 

如需 .NET Framework 4.7.1 中的 WPF 協助工具改善詳細資訊;請參閱 WPF 的協助工具改善For more information on WPF accessibility improvements in .NET Framework 4.7.1, see Accessibility improvements in WPF.

Windows Forms 協助工具改善Windows Forms accessibility improvements

在 .NET Framework 4.7.1 中,Windows Forms (WinForms) 包含下列領域的協助工具變更。In .NET Framework 4.7.1, Windows Forms (WinForms) includes accessibility changes in the following areas.

高對比模式中改善的顯示Improved display in High Contrast mode

從 .NET Framework 4.7.1 開始,各種 WinForms 控制項都提供作業系統適用的高對比模式呈現改善。Starting with .NET Framework 4.7.1, various WinForms controls offer improved rendering in the HighContrast modes available in the operating system. Windows 10 已變更某些高對比系統色彩的值,而且 Windows Forms 是以 Windows 10 Win32 架構為基礎。Windows 10 has changed the values for some high contrast system colors, and Windows Forms is based on the Windows 10 Win32 framework. 為獲得最佳體驗,請在最新版的 Windows 上執行,並新增最新 OS 變更,方法是在測試應用程式中新增 app.manifest 檔案,並將 Windows 10 支援的 OS 列取消註解,使它看起來如下:For the best experience, run on the latest version of Windows and opt in to the latest OS changes by adding an app.manifest file in a test application and un-comment the Windows 10 supported OS  line so that it looks the following:

<!-- Windows 10 -->
<supportedOS Id=”{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}” />

一些高對比變更範例包含:Some examples of high contrast changes include:

  • MenuStrip 項目中的核取記號較容易檢視。Checkmarks in MenuStrip items are easier to view.

  • 選取時,已停用 MenuStrip 項目較容易檢視。When selected, disabled MenuStrip items are easier to view.

  • 所選取 Button 控制項中的文字會與選取色彩成對比。Text in a selected Button control contrasts with the selection color.

  • 已停用的文字較容易閱讀。Disabled text is easier to read. 例如:For example:

    之前:Before:

    協助工具改善之前的已停用文字 

    之後:After:

    協助工具改善之後的已停用文字 

  • 執行緒例外狀況對話方塊中的高對比改善。High contrast improvements in the Thread Exception Dialog.

改善的朗讀程式支援Improved Narrator support

.NET Framework 4.7.1 中的 Windows Forms 包含朗讀程式的下列協助工具改善:Windows Forms in .NET Framework 4.7.1 includes the following accessibility improvements for the Narrator:

  • 朗讀程式和其他 UI 自動化工具可以存取 MonthCalendar 控制項。The MonthCalendar control can be accessed by the Narrator, as well as by other UI automation tools.

  • CheckedListBox 控制項會在項目的核取狀態已經變更,因而通知使用者它們已變更清單項目值時通知 [朗讀程式]。The CheckedListBox control notifies Narrator when an item's check state has changed so the user is notified that they’ve changed the value of a list item.

  • DataGridViewCell 控制項會向朗讀程式報告正確的唯讀狀態。The DataGridViewCell control reports the correct read-only status to Narrator.

  • 朗讀程式現在可以讀取已停用 ToolStripMenuItem 文字,而之前它會略過已停用的功能表項目。Narrator can now read disabled ToolStripMenuItem text, whereas previously it would skip over disabled menu items.

UIAutomation 協助工具模式的增強支援Enhanced support for UIAutomation accessibility patterns

從 .NET Framework 4.7.1 開始,協助工具技術工具開發人員可以利用許多 WinForms 控制項的一般 API 協助工具模式和屬性。Starting with .NET Framework 4.7.1, developers of accessibility technology tools can leverage common API accessibility patterns and properties for several WinForms controls. 這些協助工具改善包含:These accessibility improvements include:

改善的屬性瀏覽器體驗Improved property browser experience

從 .NET Framework 4.7.1 開始,Windows Forms 包含:Starting with .NET Framework 4.7.1, Windows Forms includes:

  • 透過各種下拉式選取視窗進行更佳的鍵盤導覽。Better keyboard navigation through the various drop-down selection windows.
  • 減少不必要的定位停駐點。A reduction of unnecessary tab stops.
  • 更適當地報告控制項類型。Better reporting of control types.
  • 改善的朗讀程式行為。Improved narrator behavior.

ASP.NET Web 控制項ASP.NET web controls

從 .NET Framework 4.7.1 和 Visual Studio 2017 15.3 版開始,ASP.NET 改善了 ASP.NET web 控制項如何與 Visual Studio 中的協助工具技術搭配使用。Starting with .NET Framework 4.7.1 and Visual Studio 2017 version 15.3, ASP.NET improves how ASP.NET web controls work with accessibility technology in Visual Studio. 變更包括下列項目:Changes include the following:

  • 在控制項中,實作遺漏 UI 協助工具模式的變更,例如在 [詳細資料檢視精靈] 的 [新增欄位] 對話方塊或 [ListView 精靈] 的 [設定 ListView] 對話方塊。Changes to implement missing UI accessibility patterns in controls, like the Add Field dialog in the Details View wizard, or the Configure ListView dialog of the ListView wizard.

  • 改善高對比模式顯示的變更,例如資料頁面巡覽區欄位編輯器Changes to improve the display in High Contrast mode, like the Data Pager Fields Editor.

  • 改善控制項鍵盤瀏覽體驗的變更,例如 DataPager 控制項 [編輯頁面巡覽區欄位精靈] 的 [欄位] 對話方塊、[設定 ObjectContext] 對話方塊,或 [設定資料來源精靈] 的 [設定資料選取項目] 對話方塊。Changes to improve the keyboard navigation experiences for controls, like the Fields dialog in the Edit Pager Fields wizard of the DataPager control, the Configure ObjectContext dialog, or the Configure Data Selection dialog of the Configure Data Source wizard.

.NET SDK 工具.NET SDK Tools

組態編輯器工具 (SvcConfigEditor.exe)服務追蹤檢視器工具 (SvcTraceViewer.exe) 藉由修正各種協助工具問題來改善。The Configuration Editor Tool (SvcConfigEditor.exe) and Service Trace Viewer Tool (SvcTraceViewer.exe) have been improved by fixing varied accessibility issues. 其中大部分是小問題,例如未定義名稱,或未正確實作某些 UI 自動化模式。Most of these were small issues, like a name not being defined or certain UI automation patterns not being implemented correctly. 雖然許多使用者並未注意到這些不正確的值,但使用螢幕助讀程式等輔助技術的客戶會發現這些 SDK 工具更易於存取。While many users won’t be aware of these incorrect values, customers who use assistive technologies like screen readers will find these SDK tools more accessible.

這些增強功能變更一些先前的行為,例如鍵盤焦點的順序。These enhancements change some previous behaviors, such as keyboard focus order.

Windows Workflow Foundation (WF) 工作流程設計工具Windows Workflow Foundation (WF) Workflow Designer

在工作流程設計工具中的協助工具變更包括下列各項:Accessibility changes in the Workflow Designer include the following:

  • 在某些控制項中,定位順序變更為由左至右及由上至下:The tab order changes to left to right and top to bottom in some controls:

  • 可透過鍵盤使用多個功能:More functions are available via the keyboard:

    • 編輯活動的屬性時,如果第一次將焦點放在屬性群組,可以透過鍵盤將其摺疊。When editing the properties of an activity, property groups can be collapsed by keyboard the first time they are focused.

    • 可透過鍵盤存取警告圖示。Warning icons are accessible by keyboard.

    • 可透過鍵盤存取 [屬性] 視窗中的 [其他屬性] 按鈕。The More Properties button in the Properties window is accessible by keyboard.

    • 鍵盤使用者可以存取工作流程設計工具之 [引數] 和 [變數] 窗格中的標頭項目。Keyboard users can access the header items in the Arguments and Variables panes of the Workflow Designer.

  • 在以下這類情況發生時,已改善具有焦點之項目的可見性:Improved visibility of items with focus, such as when:

    • 在工作流程設計工具與活動設計工具所使用的資料格中新增資料列。Adding rows to data grids used by the Workflow Designer and activity designers.

    • 使用 Tab 鍵循環顯示 ReceiveReplySendReply 活動的欄位。Tabbing through fields in the ReceiveReply and SendReply activities.

    • 設定變數或引數的預設值Setting default values for variables or arguments

  • 螢幕助讀程式現在可以正確辨識:Screen readers can now correctly recognize:

    • 工作流程設計工具中設定的中斷點。Breakpoints set in the workflow designer.

    • FlowSwitch<T>FlowDecisionCorrelationScope 活動。The FlowSwitch<T>, FlowDecision, and CorrelationScope activities.

    • Receive 活動的內容。The contents of the Receive activity.

    • InvokeMethod 活動的目標類型。The Target Type for the InvokeMethod activity.

    • TryCatch 活動中的例外狀況下拉式方塊和 Finally 區段。The Exception combo box and the Finally section in the TryCatch activity.

    • 傳訊活動 (ReceiveSendSendReplyReceiveReply) 中的 [訊息類型] 下拉式方塊、[新增關聯性初始設定式] 視窗、[內容定義] 視窗和 [CorrelatesOn 定義] 視窗。The Message Type combo box, the splitter in the Add Correlation Initializers window, the Content Definition window, and the CorrelatesOn Definition window in the messaging activities (Receive, Send, SendReply, and ReceiveReply).

    • 狀態機器轉換和轉換目的地。State machine transitions and transitions destinations.

    • FlowDecision 活動的註釋和連接器。Annotations and connectors on FlowDecision activities.

    • 活動的操作 (右鍵) 功能表。The context (right-click) menus for activities.

    • 屬性方格中的屬性值編輯器、[清除搜尋] 按鈕、[依分類] 及 [字母順序] 排序按鈕和 [運算式編輯器] 對話方塊。The property value editors, the Clear Search button, the By Category and Alphabetical sort buttons, and the Expression Editor dialog in the properties grid.

    • 工作流程設計工具中的顯示比例百分比。The zoom percentage in the Workflow Designer.

    • ParallelPick 活動中的分隔符號。The separator in Parallel and Pick activities.

    • InvokeDelegate 活動。The InvokeDelegate activity.

    • 字典活動 (Microsoft.Activities.AddToDictionary<TKey,TValue>Microsoft.Activities.RemoveFromDictionary<TKey,TValue> 等) 的 [選取類型] 視窗。The Select Types window for dictionary activities (Microsoft.Activities.AddToDictionary<TKey,TValue>, Microsoft.Activities.RemoveFromDictionary<TKey,TValue>, etc.).

    • [瀏覽並選取 .NET 類型] 視窗。The Browse and Select .NET Type window.

    • 工作流程設計工具中的階層連結。Breadcrumbs in the Workflow Designer.

  • 選擇高對比佈景主題的使用者會看到工作流程設計工具和其控制項在可見性方面的許多改善,例如項目之間的更佳對比比例以及用於焦點項目的更明顯選取方塊。Users who choose High Contrast themes will see many improvements in the visibility of the Workflow Designer and its controls, like better contrast ratios between elements and more noticeable selection boxes used for focus elements.

請參閱See also