2

I am writing a WPF (.net 5) application which should support accessibility specifically windows narrator to read out the screen text. I am using few TextBlocks and expect that as soon as window is shown narrator will start reading all the text present in the screen one by one.

What I observe is that while the Button's content are read out, any TextBlock content is not read by narrator at all.

How can I make the narrator to read all the content of the window one by one.

<Window x:Class="SampleApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:SampleApp"
        mc:Ignorable="d"
        TabIndex="0"
        Focusable="True"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
            <TextBlock x:Name="firstText"
                       Text="This is the first line"
                       KeyboardNavigation.TabIndex="1"
                       KeyboardNavigation.TabNavigation="Continue"
                       AutomationProperties.AutomationId="firstTextBox"
                       AutomationProperties.Name="This is the first line"
                       />
            <TextBlock x:Name="secondText"
                       Text="This is the second line"
                       KeyboardNavigation.TabIndex="2"
                       KeyboardNavigation.TabNavigation="Continue"
                       AutomationProperties.AutomationId="secondTextBox"
                       AutomationProperties.Name="This is the second line"
                       />
        </StackPanel>

    </Grid>
</Window>
Amit
  • 21
  • 1

1 Answers1

0

Here is a style I use that makes each textblock focusable when the Narrator is on, but does not create a bunch of extra tabs stops if Narrator is off.

    <!-- WCAG variant -->
    <Style x:Key="WCAG_TextboxStyle" TargetType="{x:Type TextBlock}" 
           BasedOn="{StaticResource {x:Type TextBlock}}" >
    <Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
    <Setter Property="Focusable" Value="False"/>
    <Style.Triggers>
        <DataTrigger Binding="{Binding IsNarratorOn}" Value="true">
          <Setter Property="KeyboardNavigation.IsTabStop" Value="True"/>
          <Setter Property="Focusable" Value="True"/>
        </DataTrigger>
     </Style.Triggers>
    </Style>