【问题标题】:Windows phone app, how to use narrator read page title automatically?Windows 手机应用程序,如何使用旁白自动读取页面标题?
【发布时间】:2015-12-25 05:25:49
【问题描述】:

我正在手机上开发 Windows 通用应用程序(XAML、C#),并为讲述人启用辅助功能。有人知道如何让旁白在打开页面时自动读取页面标题吗?

我尝试在页面中设置automationproperties.name 但没有成功:

<Page
x:Class="xxxxxx"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
AutomationProperties.Name="Page title to be read"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

【问题讨论】:

    标签: windows accessibility uwp narrator


    【解决方案1】:

    当您在列表中选择控件或编辑文本框时,将应用 UWP 讲述人的功能。如果您想在应用打开时阅读内容,您应该使用 SpeechSynthesizer API,它非常容易实现:

    1.- 在 XAML 中添加一个媒体元素

        <MediaElement x:Name="MediaElement"/>
    

    2.-然后在页面后面的代码中:

     public MainPage()
        {
            this.InitializeComponent();
            this.Loaded += MainPage_Loaded;
        }
    
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            ReadTitle();
        }
    
        private async void ReadTitle()
        {
            var voice = SpeechSynthesizer.AllVoices.First();
            SpeechSynthesizer reader = new SpeechSynthesizer() { Voice = voice };
            var text= this.GetValue(AutomationProperties.NameProperty) as String; 
            await reader.SynthesizeTextToStreamAsync(text);
    
            MediaElement.SetSource(stream, stream.ContentType);
            MediaElement.Play();
        }
    

    你可以读取任何你想将字符串传递给阅读器的内容。

    【讨论】:

      【解决方案2】:

      您需要让旁白可以查看。我不相信您可以在 Page Class 中声明 Name 属性。在您的主页内容中尝试这样的操作:

      <HyperlinkButton
          NavigateUri="www.bing.com"
          AutomationProperties.AutomationID="bing url" //Not Required to work
          AutomationProperties.Name="Go to the Bing Homepage"//Narrator will read this
          <StackPanel>
             <TextBlock Text="Bing Dot Com" />
             <TextBlock Text="www.bing.com" />
          <StackPanel>
      </HyperlinkButton>
      

      https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.automation.peers.accessibilityview

      编辑:您可能还需要以编程方式将焦点设置在该项目上才能正常工作

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-15
        • 1970-01-01
        • 1970-01-01
        • 2017-06-21
        • 1970-01-01
        相关资源
        最近更新 更多