Accessibility MenuItem PositionInSet is not getting correctly set in certain situations
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
* .NET Core Version: 3.1
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Unknown
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No
* Security issues and bugs should be reported privately, learn more via our [responsible disclosure guidelines](https://github.com/dotnet/wpf/blob/main/README.md#reporting-security-issues-and-security-bugs).
**Problem description:**
When populating the subMenuItems in the code-behind, narrator announces the positionInSet / SizeOfSet. This doesn't happen when using the ItemsSource and (optionally) modifying the ContainerStyle in .xaml code.
If you have a menuItem with an itemSource (optionally with a container style), the positionIsSet automation property does not get set correctly and narrator subsequently does not read positionInSet / sizeOfSet. positionInSet does seem to work when each menuItem is added using an event handler for subMenuOpened.
**Actual behavior:**
Windows narrator does not announce "positionInSet of sizeOfSet" when menuItems are set through .xaml file ItemsSource. Only works when set in codebehind.
**Expected behavior:**
positionInSet should always be set no matter how the menuItem is instantiated. Windows narrator should always announce "positionInSet of sizeOfSet".
**Minimal repro:**
*This does not announce positionInSet / sizeOfSet*
```
<Setter Property="MenuItem.Header" Value="{Binding File, Mode=OneTime}" />
```
vs.
*When populating in the code-behind, the positionInSet is properly set and announced.*
.xaml file
```
```
.xaml.cs file (codebehind)
```
this.openMenuItem.ItemsSource = SomeSourceCollection
.Select((menuItemHeader, index) =>
{
var subMenuItem = new MenuItem()
{
Header = menuItemHeader,
};
return subMenuItem ;
});
```
Contributor guide
Assessment
This issue has not been assessed yet.