[英]How to make narrator correctly treat groups in NavigationView
I have simple navigation view:我有简单的导航视图:
<NavigationView>
<NavigationView.MenuItems>
<NavigationViewItemHeader Content="Home"/>
<NavigationViewItem Content="Customers"/>
<NavigationViewItem Content="Orders"/>
<NavigationViewItemSeparator/>
<NavigationViewItemHeader Content="Reports"/>
<NavigationViewItem Content="Customers"/>
<NavigationViewItem Content="Orders"/>
<NavigationViewItem Content="Sales"/>
<NavigationViewItemSeparator/>
<NavigationViewItemHeader Content="Sales Charts"/>
<NavigationViewItem Content="Customer"/>
<NavigationViewItem Content="Product"/>
<NavigationViewItem Content="Time"/>
</NavigationView.MenuItems>
<ContentFrame/>
</NavigationView>
You can see there are groups defined using NavigationViewItemHeader
and NavigationViewItemSeparator
.您可以看到使用NavigationViewItemHeader
和NavigationViewItemSeparator
定义的组。 Narrator does not take account of this and reads all items as if they were flat members of the same collection. “讲述人”没有考虑到这一点,而是将所有项目视为同一集合的平面成员。 I cannot group these items in <Grid>
or <StackPanel>
(as recommended in msft docs), as NavigationView
does not render such items at all.我无法在<Grid>
或<StackPanel>
中对这些项目进行分组(如 msft 文档中所建议的那样),因为NavigationView
根本不会呈现这些项目。
How I can achieve good results without manually creating automation peers and specifying my own groups?如何在不手动创建自动化对等点和指定我自己的组的情况下取得良好的结果?
I think there isn't much you can do without wrapping them (which you said doesn't work, might work on the WInUI 2 one though) or creating an AutomationPeer since the NavigationView automationpeer treats each of them as a separate item (as they are).我认为如果不包装它们(你说这不起作用,可能在 WInUI 2 上工作)或创建一个 AutomationPeer,你无能为力,因为 NavigationView 自动化对等体将它们中的每一个视为一个单独的项目(因为它们是)。 If you need more granual control over this (having groups etc), hierarchical NavigationViewItems might be a good workaround/solution如果您需要对此进行更细致的控制(具有组等), 分层 NavigationViewItems可能是一个很好的解决方法/解决方案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.