dotnet / dotnet/wpf

UI Automation fails to correctly recognize ListView items on a DPI Unaware application

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

Description

### Description

When you execute the `AutomationElement.FromPoint` method on a `ListView` that is placed in a DPI Unaware application window, it returns an item that is not under the specified point.

### Reproduction Steps

1. Develop a DPI-unaware application that contains a `ListView` with at least two items.
2. Create a separate WPF application that retrieves the current mouse position and includes the following code:
```csharp
POINT pt;
GetCursorPos(out pt);
Point pt2 = new Point(pt.X, pt.Y);
AutomationElement ae = AutomationElement.FromPoint(pt2);
```
Append `ae.Current.Name` to a TextBox.

3. In the Settings app, navigate to "System > Display" and set the scale to "150%".

4. Launch the DPI-unaware application.

5. Launch the WPF application.

6. Position the mouse cursor just below the midpoint of the first item in the ListView within the DPI-unaware application.

7. After a short delay, review the results appended to the TextBox in the WPF application to verify detection accuracy.

### Expected behavior

Finds item1

### Actual behavior

Finds item2

### Regression?

NO

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

_No response_

### Other information

The same behavior is also observable in the `.NET Framework`, and it is by design. Since the `.NET Framework` is in maintenance mode, we are not implementing any new features and behavioral changes for it. Adding any new features or behavioral changes to `.NET Framework` is risky and may destabilize the product. Therefore, the `.NET Framework` will continue to exhibit the same behavior, and it is by design.

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.