Hi, @fatih uyanık. Welcome to Microsoft Q&A.
You could set AutomationProperties.Name
in controls (such as TextBox
, RadioButton
, CheckBox
) to specify the words to be spoken. Refer to the following example:
1.Editing Code
<Grid x:Name="MyGrid" Width="200" Height="180" >
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border BorderBrush="Black" BorderThickness="2" Padding="5" >
<TextBox AutomationProperties.Name="{Binding Text, RelativeSource={RelativeSource Mode=Self}}" ></TextBox>
</Border>
<Border BorderBrush="Black" BorderThickness="2" Padding="5" Grid.Row="1">
<StackPanel>
<RadioButton GroupName="Sex" Content="A" AutomationProperties.Name="You clicked radio button A"></RadioButton>
<RadioButton GroupName="Sex" Content="B" AutomationProperties.Name="You clicked radio button B"></RadioButton>
</StackPanel>
</Border>
<Border BorderBrush="Black" BorderThickness="2" Padding="5" Grid.Row="2">
<StackPanel>
<CheckBox Content="C" Grid.Row="2" Grid.Column="1" AutomationProperties.Name="You clicked CheckBox C"></CheckBox>
<CheckBox Content="D" Grid.Row="2" Grid.Column="1" AutomationProperties.Name="You clicked CheckBox D"></CheckBox>
<CheckBox Content="E" Grid.Row="2" Grid.Column="1" AutomationProperties.Name="You clicked CheckBox E"></CheckBox>
</StackPanel>
</Border>
</Grid>
2.Open Narrator
on Windows: Ctrl+Win+Enter
At this time, when you modify the content of the control, the corresponding words will be spoken.
To read the error message, you coud refer to the following method:
1.Editing Code
<TextBlock x:Name="errorMessageTextBlock" Width="0" Height="0"
AutomationProperties.LiveSetting="Polite"
Visibility="Collapsed"/>
public void ShowErrorMessage()
{
string message = "This is a Test";
errorMessageTextBlock.Text = message;
errorMessageTextBlock.Visibility = Visibility.Visible;
// Create an automation peer for the TextBlock
var peer = UIElementAutomationPeer.CreatePeerForElement(errorMessageTextBlock);
if (peer != null)
{
// Raise the LiveRegionChanged event
peer.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
}
}
2.Open Narrator
on Windows: Ctrl+Win+Enter
Now when you run ShowErrorMessage()
, you will hear the error message.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.