I have an application that contains custom WPF Windows that are used to show a popup similar to the Win32 MessageBox.
As part of the requirements the application must be accessible through Screen Readers, and specifically JAWS. I have had problems getting the screen reader to read out the text in the dialog, but it will read the values in the buttons ok.
The code in the XAML is as follows
<Window x:Class="UserControls.ModalDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:converters="clr-namespace:UserControls.Converters"
mc:Ignorable="d"
d:DesignHeight="160" d:DesignWidth="400" MinHeight="85" MinWidth="400" MaxWidth="400" SizeToContent="Height" Height="Auto"
WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Title="Popup Dialog">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<StackPanel.Resources>
<converters:DisplayIconToSystemIconConverter x:Key="DisplayIconToSystemIconConverter"/>
</StackPanel.Resources>
<Image Source="{Binding IconType, Converter={StaticResource DisplayIconToSystemIconConverter}}" Height="32" Width="32" Margin="0,0,10,0"/>
<TextBlock Name="TextBlock" Margin="20,10,0,0" TextWrapping="Wrap" Width="350" Foreground="DarkSlateGray" FontSize="10" FontWeight="Normal">
<Run Text="Some text in the dialog"/>
</TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,5,0">
<Button Name="Option1Button" Content="OK" Padding="5,0,5,0" Margin="0,20,5,0" MinWidth="100" IsDefault="True" />
<Button Cancel Padding="5,0,5,0" Margin="2,20,10,0" MinWidth="75" IsCancel="True" Visibility="Visible"/>
</StackPanel>
</StackPanel></Window>
This code displays the popup correctly when called, but the screen reader only reads the title twice.
If I add an empty ListView control into the Window as the next element after the TextBlock, the screen reader correctly reads the dialog text, despite the two controls not being explicitly linked, but I cannot have an extra control like this in the control as it will affect the layout.
Is there a way to get the screen reader to correctly read the TextBlock text without having the list view in the control as well?