Skip to content

Accessibility MenuItem PositionInSet is not getting correctly set in certain situations #5263

Open
@anramanath

Description

@anramanath
  • .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.

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

<MenuItem Header="Open"
                    AutomationProperties.AutomationId="AID_Open"
                    ItemsSource="{Binding SomeSourceCollection, Mode=OneWay}">
                            <MenuItem.ItemContainerStyle>
                                <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
                                    <Setter Property="MenuItem.Header" Value="{Binding File, Mode=OneTime}" />
                                </Style>
                            </MenuItem.ItemContainerStyle>
                        </MenuItem>

vs.

When populating in the code-behind, the positionInSet is properly set and announced.

.xaml file

<MenuItem x:Name="openMenuItem" 
                                  Header="Open"
                                  AutomationProperties.AutomationId="AID_Open"/>

.xaml.cs file (codebehind)

this.openMenuItem.ItemsSource = SomeSourceCollection
                .Select((menuItemHeader, index) =>
                {
                    var subMenuItem = new MenuItem()
                    {
                        Header = menuItemHeader,
                    };

                    return subMenuItem ;
                });

Metadata

Metadata

Assignees

No one assigned

    Labels

    AccessibilityAn issue related to accessibility enhancements or blockers.InvestigateRequires further investigation by the WPF team.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions