c# - 屏幕阅读器阅读禁用按钮的 AutomationProperty.Id

标签 c# wpf button accessibility screen-readers

我添加了一个简单的 WPF 窗口,其中有两个按钮。 这些按钮通过特定逻辑变得可见,并具有更改其 VisibilityIsEnabled 属性的绑定(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/

相关文章:

c# - 如何连接到 MySQL 数据库?

c# - ElementHost 大小导致 wpf 打开/加载速度慢且内存使用率高

java - 每个 Action 监听器的单独类(class)?

javascript - HTML 按钮在 $compile 后显示为文本

button - 汉堡菜单图标和三个垂直点图标叫什么?

C# 接口(interface)约束

c# - 将事件或命令分配给 ResourceDictionary 中的 DataTemplate

c# - 将 WPF 程序移动到 Linux

wpf - 使用 Dispatcher 在 WPF 列表框中异步加载项目列表

c# - 在java中检查.net签名时出现问题