dotnet / dotnet/wpf

UIAutomation not able to inspect views inside ControlTemplate

Open
#10,981 0 comments 1 reaction 0 assignees View on GitHub
Accessibility Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

UIAutomation is not able to inspect views inside the ControlTemplate, it only retuns `AutomationPeer`s for child items.

Window:

Image

UIA tree (Note "My Custom ItemsControl" is not visible):

Image

Relevant code:

https://github.com/dotnet/wpf/blob/900946a8e06533fd7ea8909d91b0c879a7c1f9be/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ItemsControlAutomationPeer.cs#L54-L194

### Reproduction Steps

XAML

```























```

.cs

```
using System.Collections.ObjectModel;
using System.Windows;

namespace CustomItemsControlDemo
{
public partial class MainWindow : Window
{
public ObservableCollection Items { get; set; }

public MainWindow()
{
InitializeComponent();

// Sample data
Items = new ObservableCollection
{
new CardItem { Title = "Card 1", Description = "This is the first card." },
new CardItem { Title = "Card 2", Description = "This is the second card with more text to demonstrate wrapping." },
new CardItem { Title = "Card 3", Description = "Another sample card." }
};

DataContext = this;
}
}

public class CardItem
{
public string Title { get; set; }
public string Description { get; set; }
}
}

```

### Expected behavior

UIAutomation should be able to access elements in the template.

### Actual behavior

UIAutomation is not able to access elements in the template.

### Regression?

_No response_

### Known Workarounds

Dont include any items intended to be seen by UIA inside the `ControlTemplate`.

### Impact

No `ItemsControl` `ControlTemplate` is able to be read by an UIA client.

### Configuration

OS: Windows 11 24H2
inspect.exe
Target Application: WPF

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.