WPF Live-Regions 仅适用于讲述人? [英] WPF Live-Regions just for Narrator?
问题描述
我有一个带有 AutomationProperties.LiveSettings="Assertive"
的文本块 (ContentTextBlock
).我只是在测试和检查这个功能有多大用处.而且……到目前为止我很失望.
I have a textblock (ContentTextBlock
) with AutomationProperties.LiveSettings="Assertive"
. I'm just testing and checking how useful this feature is. And... am disappointed so far.
private void Button_Click(object sender, RoutedEventArgs e)
{
ContentTextBlock.Text += " test";
var peer = UIElementAutomationPeer.FromElement(ContentTextBlock);
if(peer == null)
{
peer = UIElementAutomationPeer.CreatePeerForElement(ContentTextBlock);
peer.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
}
peer.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
}
使用讲述人时,这如宣传的那样工作.每当单击按钮时,讲述人都会宣布 TextBlock 文本(test"test test"test test test")......但是当我使用 NVDA 或 JAWS 时,没有任何反应,尽管屏幕阅读器版本相对最新.他们真的没有添加对实时区域的任何支持,还是我只是遗漏了一个重要点?
When using Narrator, this works as advertised. Whenever clicking the button, Narrator announces the TextBlock text ("test" "test test" "test test test")... But when I use NVDA or JAWS, nothing happens, although the screenreader versions are relatively up-to-date. Did they really not add any support for live-regions or am I just missing an important point?
推荐答案
虽然我没有设法让实时区域工作,但我找到了另一种解决方法:
Whilst I didn't manage to get live regions to work, I found another workaround:
Tolk 是一个库,它可以,其中包括
Tolk is a library which can, among oterrs
- 检测正在运行的受支持的屏幕阅读器(如果有)
- 将字符串传递给屏幕阅读器的语音引擎和盲文.
- 还支持 SAPI
要在您的 C# 项目中包含 Tolk,请从上面的链接下载它,然后在您的项目中包含 tolk.cs
(来自 src/dotnet
),并将 tolk.dll
(它位于 bin
中)包含在您的可执行文件(或 PATH 变量中的某处)的文件夹中.确保 dll 版本与您的 CPU 目标 (x86/x64) 匹配.对 lib 目录中的 dll 执行相同的操作.然后就可以根据examples文件夹中的代码使用了.
To include Tolk in your C# project, download it from the link above, then include tolk.cs
(from src/dotnet
) in your project, and place tolk.dll
(it's found in bin
) in the folder with your executable (or somewhere in the PATH variable). Make sure that the dll version matches your CPU target (x86/x64). Do the same for the dlls in the lib directory. Then you can use it according to the code found in the examples folder.
附注.Tolk 也适用于 Win 7,所以这是一个奖励.WPF 的实时区域仅从 Win 8 开始支持.
PS. Tolk works on Win 7 as well, so that's a bonus. The live-regions of WPF were only supported from Win 8 on.
这篇关于WPF Live-Regions 仅适用于讲述人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!