0

電話で 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}">
4

2 に答える 2

0

リスト内のコントロールを選択するか、テキスト ボックスを編集すると、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();
    }

文字列をリーダーに渡して、必要なものすべてを読み取ることができます。

于 2015-12-27T06:08:36.933 に答える
0

ナレーターで閲覧可能にする必要があります。Page クラス内で 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

編集:これを機能させるには、プログラムでアイテムにフォーカスを設定する必要がある場合もあります

于 2016-08-16T19:02:54.793 に答える