[API Proposal]: Change MenuAutomationPeer/ContextMenuAutomationPeer to inherite from ItemsControlAutomationPeer
- 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
Assessment
This issue has not been assessed yet.