Skip to content

Latest commit

 

History

History
39 lines (32 loc) · 1.48 KB

kb-common-net8-automationpeers-issue.md

File metadata and controls

39 lines (32 loc) · 1.48 KB
title description type page_title slug tags res_type
UI Automation Issue with RadGridView on .NET 8
This article provides workaround for the issue where UI Automation doesn't work in WPF after migrating to .NET 8.
troubleshooting
UI Automation Not Created in WPF Under .NET 8
kb-common-net8-automationpeers-issue
radgridview, ui, automation, net8, peers
kb

Environment

Product Version
UI for WPF 2023.3.1114

Description

Automation peers cannot be accessed by UI Automation tests in a WPF project targeting .NET 8.

Solution

This is a bug in .NET 8 which is described in the following two Microsoft items:

To work it around, set the static _ItemsControlDoesNotSupportAutomation internal field of the System.Windows.AccessibilitySwitches class.

[C#]

{{region kb-common-net8-automationpeers-issue-0}} public partial class App : Application { public App() { var accessibilitySwitches = Type.GetType("System.Windows.AccessibilitySwitches, WindowsBase, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); var field = accessibilitySwitches.GetField("_ItemsControlDoesNotSupportAutomation", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static | BindingFlags.DeclaredOnly); field.SetValue(null, 1); } } {{endregion}}