Skip to content

Commit c2388bc

Browse files
Copilotayushjai19
andcommitted
Use UIHelper.AnnounceActionForAccessibility for narrator announcements without visible TextBlock
Co-authored-by: ayushjai19 <244442986+ayushjai19@users.noreply.github.com>
1 parent bd7c118 commit c2388bc

2 files changed

Lines changed: 8 additions & 18 deletions

File tree

WinUIGallery/Samples/ControlPages/PipsPagerPage.xaml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,10 @@
5151
</controls:ControlExample>
5252
<controls:ControlExample x:Name="Example2" HeaderText="PipsPager with options to change its orientation and button visibility.">
5353
<controls:ControlExample.Example>
54-
<StackPanel>
55-
<PipsPager
56-
x:Name="TestPipsPager2"
57-
NumberOfPages="10"
58-
SelectedIndexChanged="TestPipsPager2_SelectedIndexChanged" />
59-
<TextBlock
60-
x:Name="PageAnnouncementText"
61-
Margin="0,12,0,0"
62-
HorizontalAlignment="Center"
63-
AutomationProperties.LiveSetting="Polite"
64-
AutomationProperties.Name="Current page"
65-
Text="Page 1 selected" />
66-
</StackPanel>
54+
<PipsPager
55+
x:Name="TestPipsPager2"
56+
NumberOfPages="10"
57+
SelectedIndexChanged="TestPipsPager2_SelectedIndexChanged" />
6758
</controls:ControlExample.Example>
6859
<controls:ControlExample.Options>
6960
<StackPanel>

WinUIGallery/Samples/ControlPages/PipsPagerPage.xaml.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.UI.Xaml.Controls;
55
using System.Collections.Generic;
6+
using WinUIGallery.Helpers;
67

78
namespace WinUIGallery.ControlPages;
89

@@ -26,11 +27,9 @@ public PipsPagerPage()
2627

2728
private void TestPipsPager2_SelectedIndexChanged(PipsPager sender, PipsPagerSelectedIndexChangedEventArgs args)
2829
{
29-
if (PageAnnouncementText != null)
30-
{
31-
int pageNumber = sender.SelectedPageIndex + 1; // Convert 0-based index to 1-based page number
32-
PageAnnouncementText.Text = $"Page {pageNumber} selected";
33-
}
30+
int pageNumber = sender.SelectedPageIndex + 1; // Convert 0-based index to 1-based page number
31+
string announcement = $"Page {pageNumber} selected";
32+
UIHelper.AnnounceActionForAccessibility(sender, announcement, "PipsPagerPageChangeNotificationId");
3433
}
3534

3635
private void OrientationComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)

0 commit comments

Comments
 (0)