【问题标题】:How to restrict the narrator from reading the default content when the Button is focusedButton 获得焦点时如何限制叙述者阅读默认内容
【发布时间】:2019-07-24 16:40:32
【问题描述】:

我使用 UI.Xaml.Control.Button 创建了一个自定义控件,并且需要为其提供辅助功能支持。我需要设置一个自定义内容,当按钮处于焦点时向 UI 自动化框架报告。但是,由于内置 Button 行为,默认内容“双击激活”会由旁白自动读取。如何限制默认内容?

【问题讨论】:

  • 自定义内容是什么?能给我一个简单的代码示例吗?
  • @XavierXie-MSFT 我们可以使用 SetValue() 方法在源级别提供自定义内容,如下面的代码。 this.SetValue(AutomationProperties.NameProperty, "双击清除文本");

标签: c# xamarin.forms uwp


【解决方案1】:

我们可以使用 SetValue() 方法在源代码级别提供自定义内容,如下面的代码。 this.SetValue(AutomationProperties.NameProperty, "双击清除文本");

根据我的测试,你需要调用Button的SetValue()方法,而不是页面。然后,旁白将阅读更新的内容。

<Button x:Name="btn" AutomationProperties.Name="Double Tap to activate" Click="Button_Click"></Button>
private void Button_Click(object sender, RoutedEventArgs e)
{
    btn.SetValue(AutomationProperties.NameProperty, "Double tap to clear the text");
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-31
    • 2023-04-04
    • 2011-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多