简体   繁体   English

当按钮聚焦时,如何限制叙述者阅读默认内容

[英]How to restrict the narrator from reading the default content when the Button is focused

I have created a custom control using the UI.Xaml.Control.Button and need to provide Accessibility support for the same. 我已经使用UI.Xaml.Control.Button创建了一个自定义控件,并且需要为它提供可访问性支持。 I need to set a custom content that reports to the UI Automation framework when the Button is on focus. 我需要设置一个自定义内容,当Button成为焦点时向UI自动化框架报告。 But, the default content "Double Tap to activate" is automatically read by the narrator because of built-in Button behavior. 但是,由于内置的​​Button行为,讲述人会自动读取默认内容“双击以激活”。 How to restrict the default content? 如何限制默认内容?

We can give custom content in source-level using SetValue() method like the below code. 我们可以使用SetValue()方法在源代码级别提供自定义内容,如以下代码所示。 this.SetValue(AutomationProperties.NameProperty, "Double tap to clear the text"); this.SetValue(AutomationProperties.NameProperty,“双击以清除文本”);

By my test, you need to call the SetValue() method of the Button, instead of the page. 通过我的测试,您需要调用Button的SetValue()方法,而不是页面。 Then, the narrator will read the updated content. 然后,讲述人将阅读更新的内容。

<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");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM