New to Telerik UI for WPF? Download free 30-day trial

UI Automation Issue with RadGridView on .NET 8

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.

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); 
    } 
} 
In this article