{"id":14515,"date":"2017-09-21T15:00:20","date_gmt":"2017-09-21T22:00:20","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/dotnet\/?p=14515"},"modified":"2020-07-28T01:39:33","modified_gmt":"2020-07-28T08:39:33","slug":"net-framework-4-7-1-accessibility-and-wpf-improvements","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/net-framework-4-7-1-accessibility-and-wpf-improvements\/","title":{"rendered":".NET Framework 4.7.1 Accessibility and WPF Improvements"},"content":{"rendered":"<p>This post describes the new WPF and accessibility features and improvements in .NET Framework 4.7.1. You can try out these\u00a0features by downloading the\u00a0Developer Pack, described in the\u00a0<a href=\"https:\/\/blogs.msdn.microsoft.com\/dotnet\/2017\/08\/07\/welcome-to-the-net-framework-4-7-1-early-access\/\">Welcome to the .NET Framework 4.7.1 Early Access blog post<\/a>.<\/p>\n<h2>Accessibility improvements<\/h2>\n<p>.NET Framework 4.7.1 brings in a lot of accessibility improvements across different libraries to align with the broad <a href=\"https:\/\/blogs.msdn.microsoft.com\/accessibility\/2016\/12\/02\/making-microsoft-products-more-accessible-what-to-expect-in-2017\/\">Microsoft product accessibility goals<\/a>.<\/p>\n<h3>How to get these accessibility improvements?<\/h3>\n<p>In order for the application to benefit from\u00a0these changes, it needs to\u00a0run on the .NET Framework 4.7.1 or later and configured in one\u00a0of the following ways:<\/p>\n<ul>\n<li>It is recompiled to target the .NET Framework 4.7.1. <span style=\"text-decoration: underline;\">OR<\/span><\/li>\n<li>It opts out of the legacy accessibility behaviors by adding the following <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/framework\/configure-apps\/file-schema\/runtime\/appcontextswitchoverrides-element\">AppContext Switch<\/a> to the &lt;runtime&gt; section of the app config file and setting it to false, as the following example shows.<\/li>\n<\/ul>\n<p><script src=\"https:\/\/gist.github.com\/preetikr\/9301f71f6c76548ca34ef4894370ec84.js\"><\/script><\/p>\n<p>Applications that target the .NET Framework 4.7.1 or later 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 &#8220;true&#8221;.<\/p>\n<h3>WPF Accessibility improvements<\/h3>\n<p>Accessibility improvements in WPF are in the following areas:<\/p>\n<ul>\n<li>UIAutomation LiveRegion support<\/li>\n<li>Screen Readers<\/li>\n<li>High Contrast<\/li>\n<\/ul>\n<h4>UIAutomation LiveRegion Support<\/h4>\n<p>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\u2019s currently focused. However, if a UI element changes somewhere in the screen and it is not being focused at that point in time, the user may not be notified, and so they may be missing important information.<\/p>\n<p>LiveRegions are meant to solve this problem. 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 make decisions of its own as to how and when to inform the user of this change. The LiveSetting property also informs\u00a0the screen reader of the importance of the UI change to the\u00a0user.<\/p>\n<p>LiveSettingProperty and LiveRegionChangedEvent have been added to System.Windows.Automation.AutomationElementIdentifiers, settable via XAML.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/preetikr\/b559b1be8007697da1f23848a33b5760.js\"><\/script><\/p>\n<p>A new DependencyProperty is now\u00a0registered for \u201cLiveSetting\u201d under System.Windows.Automation.AutomationProperties, as well as Set and Get methods. System.Windows.Automation.Peers.AutomationPeer now has a new method GetLiveSettingCore, which can be overridden to provide a LiveSetting value.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/preetikr\/7b3e9393bc561d3105cb93a9c3d39ea6.js\"><\/script><\/p>\n<p>A new enumeration for the possible values of LiveSetting has been added to System.Windows.Automation.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/preetikr\/ca2d92a9412b30085c20a6f67df3376f.js\"><\/script><\/p>\n<h5>How to make a LiveRegion?<\/h5>\n<p>You can set\u00a0the AutomationProperties.LiveSetting property on the element of interest to make it a \u201cLiveRegion\u201d as shown in the following sample.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/preetikr\/f487e3dd516a9090097f7e39e362ab0b.js\"><\/script><\/p>\n<h5>Announcing an important UI change<\/h5>\n<p>When the data changes on your LiveRegion, and you feel the need to inform a screen reader about that change, you need to explicitly raise an event as illustrated by the following sample.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/preetikr\/959bdab31fcb1e5e4a5b186da5b09516.js\"><\/script><\/p>\n<h4>Screen reader<\/h4>\n<p>You can observe the following accessibility improvements in the screen reader area after you opt-in to the Accessibility improvements in .NET Framework 4.7.1.<\/p>\n<ul>\n<li>In previous versions, Expanders were announced by screen readers as buttons, they are now correctly announced as groups (expand\/collapse).<\/li>\n<li>In previous releases, DataGridCells were announced by screen readers as \u201ccustom\u201d, they are now correctly announced as data grid cell (localized).<\/li>\n<li>Now Screen readers will\u00a0announce the name of an editable ComboBox.<\/li>\n<li>In previous releases, PasswordBoxes were announced as \u201cno item in view\u201d or had otherwise incorrect behavior, this issue is now fixed.<\/li>\n<\/ul>\n<h4>High Contrast<\/h4>\n<p>There are High Contrast improvements in various WPF controls and they are visible when High Contrast theme is set.<\/p>\n<h6>Expander control<\/h6>\n<p>The focus visual for the expander control is now visible. The\u00a0keyboard visuals for combo-box, list-box and radio buttons are visible as well.<\/p>\n<p><em>Before:<\/em>\u00a0<img decoding=\"async\" class=\"alignnone size-full wp-image-14675\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/401856-Before.png\" alt=\"\" width=\"159\" height=\"28\" \/><\/p>\n<p><em>After:<\/em>\u00a0<img decoding=\"async\" class=\"alignnone size-full wp-image-14685\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/401856-After.png\" alt=\"\" width=\"167\" height=\"37\" \/><\/p>\n<h6>CheckBox and RadioButton<\/h6>\n<p>The text in CheckBox and RadioButton is now easier to see when selected in high contrast themes.<\/p>\n<p><em>Before:<\/em>\u00a0<img decoding=\"async\" class=\"alignnone size-medium wp-image-14695\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/431603-Before-300x40.png\" alt=\"\" width=\"300\" height=\"40\" \/><\/p>\n<p><em>After:<\/em>\u00a0<img decoding=\"async\" class=\"alignnone size-medium wp-image-14696\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/431603-After-300x42.png\" alt=\"\" width=\"300\" height=\"42\" \/><\/p>\n<h6>ComboBox<\/h6>\n<p>The border of a disabled ComboBox is now the same color as disabled text.<\/p>\n<p><em>Before:<\/em>\u00a0<img decoding=\"async\" class=\"alignnone size-medium wp-image-14705\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437426-Before-300x27.png\" alt=\"\" width=\"300\" height=\"27\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437426-Before-300x27.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437426-Before.png 385w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><em>After:<\/em> \u00a0\u00a0<img decoding=\"async\" class=\"alignnone size-medium wp-image-14706\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437426-After-300x27.png\" alt=\"\" width=\"300\" height=\"27\" \/><\/p>\n<p>Disabled and focused buttons use the correct theme color.<\/p>\n<p><em>Before:<\/em>\u00a0<img decoding=\"async\" class=\"alignnone size-medium wp-image-14715\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437425-Before-300x31.png\" alt=\"\" width=\"300\" height=\"31\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437425-Before-300x31.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437425-Before.png 391w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><em>After:<\/em>\u00a0<img decoding=\"async\" class=\"alignnone size-medium wp-image-14725\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437425-After-300x28.png\" alt=\"\" width=\"300\" height=\"28\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437425-After-300x28.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437425-After.png 388w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Setting a ComboBox\u2019s style to Toolbar, ComboBoxStyleKey caused the dropdown arrow to be invisible, this issue is now fixed.<\/p>\n<p><em>Before:<\/em>\u00a0<img decoding=\"async\" class=\"alignnone size-full wp-image-14727\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437424-Before.png\" alt=\"\" width=\"38\" height=\"31\" \/><\/p>\n<p><em>After:<\/em>\u00a0<img decoding=\"async\" class=\"alignnone size-full wp-image-14735\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/437424-After.png\" alt=\"\" width=\"49\" height=\"32\" \/><\/p>\n<h6>DataGrid<\/h6>\n<p>The sort indicator arrow in DataGrid now uses correct theme colors.<\/p>\n<p><em>Before:<\/em>\u00a0<img decoding=\"async\" class=\"alignnone size-full wp-image-14736\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/436104-Before.png\" alt=\"\" width=\"179\" height=\"65\" \/><\/p>\n<p><em>After:<\/em> \u00a0\u00a0<img decoding=\"async\" class=\"alignnone size-full wp-image-14746\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/436104-After.png\" alt=\"\" width=\"173\" height=\"63\" \/><\/p>\n<p>Previously, default link style changed to incorrect color on mouse over in high contrast modes and this is now resolved. Similarly, DataGrid checkbox column now uses the expected colors for keyboard focus feedback.<\/p>\n<p><em>Before:<\/em>\u00a0<img decoding=\"async\" class=\"alignnone size-full wp-image-14755\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/443935-Before.png\" alt=\"\" width=\"60\" height=\"21\" \/><\/p>\n<p><em>After:<\/em>\u00a0 \u00a0\u00a0<img decoding=\"async\" class=\"alignnone size-full wp-image-14756\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2017\/09\/443935-After.png\" alt=\"\" width=\"55\" height=\"24\" \/><\/p>\n<h3>Windows Forms Accessibility improvements<\/h3>\n<p>Windows Forms accessibility changes are in the following areas. We will talk about these in detail in an upcoming blog post.<\/p>\n<ul>\n<li>Improved display during High Contrast mode<\/li>\n<li>Improved property browser experience<\/li>\n<li>Enhanced\u00a0UI accessibility patterns<\/li>\n<\/ul>\n<h2>WPF &#8211; Changing implicit data templates<\/h2>\n<p>This feature enables the automatic update of elements that use implicit DataTemplates after changing a resource.\u00a0When an application adds, removes, or replaces a value declared in a\u00a0ResourceDictionary, WPF automatically updates all elements that use\u00a0the value in most cases, including the implicit style case:<em>\u00a0&lt;Style TargetType=&#8221;Button&#8221;<\/em>. Here\u00a0the value should apply to all buttons in the scope of the resource.\u00a0This feature supports a similar update in the implicit data template case where the value should\u00a0apply to all in-scope ContentPresenters whose content is a Book:\u00a0<em>&lt;DataTemplate DataType=&#8221;{x:Type local:Book}&#8221;&gt;\u00a0<\/em><\/p>\n<p>This feature&#8217;s principal client is Visual Studio&#8217;s &#8220;Edit-and-Continue&#8221; facility, when a user changes a DataTemplate resource in a running application and expects to see the effect of that change when the\u00a0application continues. However it could also prove useful to\u00a0any application with changing DataTemplate resources.<\/p>\n<p>The feature is controlled by a new property ResourceDictionary.InvalidatesImplicitDataTemplateResources. After setting this to True, any changes \u00a0to DataTemplate resources in the dictionary will cause all ContentPresenters in the scope\u00a0of the dictionary to re-evaluate their choice of DataTemplate.\u00a0This is a moderately expensive process &#8211; our recommendation is to not to enable it\u00a0unless you really need it.<\/p>\n<h2>WPF &#8211;\u00a0Distinguishing dynamic values in a template<\/h2>\n<p>This feature enables a caller to determine whether a value obtained\u00a0from a template is &#8220;dynamic&#8221;.\u00a0Diagnostic assistants, such as Visual Studio&#8217;s &#8220;Edit-and-Continue&#8221; facility, need to know whether a templated value is dynamic, in order to propagate a user&#8217;s changes correctly.<\/p>\n<p>The feature is implemented by a new method on the class DependencyPropertyHelper:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/preetikr\/59a74d2996c7beb776e541c481a77204.js\"><\/script><\/p>\n<p>This returns true if the template&#8217;s value for the given property is &#8220;dynamic&#8221;, that is if it declared via DynamicResourceReference or TemplateBinding, or via Binding or one of its derived classes.<\/p>\n<h2>WPF &#8211; SourceInfo for elements in templates<\/h2>\n<p>Diagnostic assistants such as Visual Studio&#8217;s &#8220;Edit-and-Continue&#8221; facility can use SourceInfo to locate the file and line number where a given element was declared. \u00a0The SourceInfo is now\u00a0available for elements declared in a template loaded from XAML (as opposed to compiled BAML). This enables diagnostic assistants to do a better job.\u00a0This feature is enabled automatically whenever SourceInfo itself is enabled.<\/p>\n<h2>WPF &#8211; Enable Visual Diagnostics<\/h2>\n<p>This feature provides a number of ways to control the VisualDiagnostic features. Diagnostic assistants can request WPF to share internal information. This feature gives both the assistant and the application developer more control over when this sharing is enabled.\nThe VisualDiagnostic features in WPF, with their introduction in .NET Framework 4.6, were initially only enabled when a managed debugger was attached. However,\u00a0scenarios have arisen involving other components (besides a debugger) that can reasonably be considered as a diagnostic assistant, e.g. Visual Studio&#8217;s design surface. Thus, the need for a public way to control the features. \u00a0The feature is controlled by two new methods on the class VisualDiagnostics, and by a number of registry keys, app-context switches, and\u00a0environment variables.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/preetikr\/04bc5b2b268c89545ac34339a8da69be.js\"><\/script><\/p>\n<p>The methods enable and disable the VisualTreeChanged event. You can only enable this event in a &#8220;diagnostic scenario&#8221;, defined as one of the following:<\/p>\n<ul>\n<li>A debugger is attached<\/li>\n<li>Windows 10 Developer Mode is set. More precisely, registry key <code>HKLMSOFTWAREMicrosoftWindowsCurrentVersionAppModelUnlockAllowDevelopmentWithoutDevLicense<\/code> has value 1<\/li>\n<li>Environment variable <code>ENABLE_XAML_DIAGNOSTICS_VISUAL_TREE_NOTIFICATIONS<\/code> is set to a value different from &#8220;0&#8221; or &#8220;false&#8221; (case-insensitive).<\/li>\n<\/ul>\n<p>Changes to the visual tree are disallowed while a VisualTreeChanged event is in progress. Specifically, an <code>InvalidOperationException<\/code> is thrown by any of the following actions:<\/p>\n<ul>\n<li>Changing a visual or logical parent<\/li>\n<li>Changing a resource dictionary<\/li>\n<li>Changing a DependencyProperty value on a <code>FrameworkElement<\/code> or <code>FrameworkContentElement<\/code>.<\/li>\n<\/ul>\n<p>This guards against unexpected and unsupported re-entrancy.<\/p>\n<p>It is possible to override this <code>InvalidOperationException<\/code>, should you encounter a situation where debugging is impeded by it. To do so, add\u00a0the following\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/framework\/configure-apps\/file-schema\/runtime\/appcontextswitchoverrides-element\">AppContext Switch<\/a>\u00a0to the &lt;runtime&gt; section of the app config file and set it to true,<\/p>\n<pre class=\"prettyprint\">Switch.System.Windows.Diagnostics.AllowChangesDuringVisualTreeChanged<\/pre>\n<p>None of the features mentioned here are supported in production applications. They are intended only for diagnostic assistance.<\/p>\n<p>Finally, you may want to run your application under the debugger, but in &#8220;production mode&#8221; without any potential interference from the VisualDiagnostic features. To do so,\u00a0add the following\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/framework\/configure-apps\/file-schema\/runtime\/appcontextswitchoverrides-element\">AppContext Switch<\/a>\u00a0to the &lt;runtime&gt; section of the app config file and set it to true,<\/p>\n<pre class=\"prettyprint\">Switch.System.Windows.Diagnostics.DisableDiagnostics<\/pre>\n<h2>Closing<\/h2>\n<p>Try out these new features in <a href=\"https:\/\/github.com\/Microsoft\/dotnet-framework-early-access\/blob\/master\/README.md\">.NET Framework 4.7.1 Early Access build shared<\/a> and please provide your feedback by\u00a0<a href=\"https:\/\/github.com\/Microsoft\/dotnet-framework-early-access\/issues\/new\">reporting an issue at the .NET Framework Early Access GitHub repository<\/a>. Stay tuned for further feature overviews\u00a0in .NET Framework 4.7.1.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post describes the new WPF and accessibility features and improvements in .NET Framework 4.7.1. You can try out these\u00a0features by downloading the\u00a0Developer Pack, described in the\u00a0Welcome to the .NET Framework 4.7.1 Early Access blog post. Accessibility improvements .NET Framework 4.7.1 brings in a lot of accessibility improvements across different libraries to align with the [&hellip;]<\/p>\n","protected":false},"author":364,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[195,509],"tags":[11,158],"class_list":["post-14515","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet-framework","category-wpf","tag-net-framework","tag-wpf"],"acf":[],"blog_post_summary":"<p>This post describes the new WPF and accessibility features and improvements in .NET Framework 4.7.1. You can try out these\u00a0features by downloading the\u00a0Developer Pack, described in the\u00a0Welcome to the .NET Framework 4.7.1 Early Access blog post. Accessibility improvements .NET Framework 4.7.1 brings in a lot of accessibility improvements across different libraries to align with the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/14515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/364"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=14515"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/14515\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=14515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=14515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=14515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}