dotnet / dotnet/wpf

[API Proposal]: Change MenuAutomationPeer/ContextMenuAutomationPeer to inherite from ItemsControlAutomationPeer

Open
#7,808 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Background and motivation

I was asked to create this API proposal for, PR #7335

For automation of UI-Tests we need to get access to menu items that are grouped (#6530). At the moment this is not possible because ``GroupItemAutomationPeer`` only creates automation peers for its children if the parent peer container is type of ``ItemsControlAutomationPeer``.

### API Proposal

Change inheritance of following types

```c#
namespace System.Windows.Automation.Peers
{
- public class MenuAutomationPeer : FrameworkElementAutomationPeer
+ public class MenuAutomationPeer : ItemsControlAutomationPeer
{
}

- public class ContextMenuAutomationPeer : FrameworkElementAutomationPeer
+ public class ContextMenuAutomationPeer : ItemsControlAutomationPeer
{
}

- public class MenuItemAutomationPeer : FrameworkElementAutomationPeer, IExpandCollapseProvider, IInvokeProvider, IToggleProvider
+ public class MenuItemAutomationPeer : ItemsControlAutomationPeer, IExpandCollapseProvider, IInvokeProvider, IToggleProvider
{
}
```
ItemsControlAutomationPeer is directly derived from FrameworkElementAutomationPeer. The above types are moved deeper into the inheritance chain.

### API Usage

This change effects how ``GroupItemAutomationPeer`` handles menu items. The API is used by tools like Ranorex for automated UI testing. In the end, the children of a menu item group should also be visible in the automation tree.

### Alternative Designs

None

### Risks

None

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.