我添加了一个简单的 WPF 窗口,其中有两个按钮。
这些按钮通过特定逻辑变得可见,并具有更改其 Visibility
和 IsEnabled
属性的绑定(bind)。
现在,我正在使用 Windows 导航器进行测试,发现默认的 Windows 导航器正在读取有关按钮的信息,即使它们不可见也是如此。
当按钮被禁用或不可见时,我应该如何使屏幕阅读器(或 Windows 默认导航器)不读取按钮?
<Button Margin="0,0,80,10" Height="25" HorizontalAlignment="Right" Name="failedButton"
VerticalAlignment="Bottom" Width="75" DataContext="{Binding InstallationViewModel}"
Command="{Binding Failed}"
Visibility="{Binding Failed,
Converter={StaticResource BooleanToVisibilityConverter}}"
Content="Failed?" />
最佳答案
Automation api 读取所有提供自动化对等体的东西。因此,如果您不希望您的 ui 元素暴露给自动化客户端,您需要覆盖 OnCreateAutomationPeer
并返回 null
。这意味着,您可以选择是否支持自动化,但不能在运行时更改它。
关于c# - 屏幕阅读器阅读禁用按钮的 AutomationProperty.Id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55231637/