Skip to content

Commit e045dd9

Browse files
sshubhaveeShubhika Shubhavee
andauthored
Announce Theme Transitions page action button updates (#2146)
<!--- Provide a general summary of your changes in the Title above --> ## Description Added accessibility announcements to the ThemeTransitionPage using UIHelper.AnnounceActionForAccessibility so that screen readers properly announce the result of user-initiated actions (e.g., adding/deleting items, refreshing content, repositioning elements, adding/clearing rectangles). Also changed var to explicit int type for value in EntranceAddButton_Click to comply with project coding conventions. ## Motivation and Context Screen readers did not announce the outcome of button actions on the Theme Transition sample page, making it inaccessible for users relying on assistive technology. Bug: [https://microsoft.visualstudio.com/OS/_workitems/edit/60914518](vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/ce099c1ed2/resources/app/out/vs/code/electron-browser/workbench/workbench.html) ## How Has This Been Tested? Manually verified by deploying WinUI Gallery Dev app locally that each button action on the Theme Transition page triggers a screen reader announcement with the expected text. Confirmed existing functionality (add, delete, reposition, entrance transitions) is unchanged. ## Screenshots (if appropriate): https://github.com/user-attachments/assets/4d395977-5d9d-4233-9689-269d5c65802b ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) --------- Co-authored-by: Shubhika Shubhavee <sshubhavee@microsoft.com>
1 parent f75841b commit e045dd9

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

WinUIGallery/Samples/ControlPages/ThemeTransitionPage.xaml.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.UI.Xaml.Shapes;
88
using System;
99
using System.Collections.Generic;
10+
using WinUIGallery.Helpers;
1011

1112
namespace WinUIGallery.ControlPages;
1213

@@ -41,6 +42,7 @@ private void ClosePopupButton_Click(object sender, RoutedEventArgs e)
4142
private void ContentRefreshButton_Click(object sender, RoutedEventArgs e)
4243
{
4344
AddItemsToContentListView(true);
45+
UIHelper.AnnounceActionForAccessibility((UIElement)sender, "Data refreshed.", "ContentRefreshNotificationId");
4446
}
4547

4648
private void AddItemsToContentListView(bool ShowDifferentContent = false)
@@ -58,38 +60,49 @@ private void AddButton_Click(object sender, RoutedEventArgs e)
5860
{
5961
AddRemoveListView.Items.Add(new ListViewItem() { Content = "New Item " + _itemCount.ToString() });
6062
_itemCount++;
63+
UIHelper.AnnounceActionForAccessibility((UIElement)sender, "Item added.", "AddDeleteItemAddedNotificationId");
6164
}
6265

6366
private void DeleteButton_Click(object sender, RoutedEventArgs e)
6467
{
6568
if (AddRemoveListView.Items.Count > 0)
69+
{
6670
AddRemoveListView.Items.RemoveAt(0);
71+
UIHelper.AnnounceActionForAccessibility((UIElement)sender, "Item deleted.", "AddDeleteItemDeletedNotificationId");
72+
}
6773
}
6874

6975
private void RepositionButton_Click(object sender, RoutedEventArgs e)
7076
{
7177
MiddleElement.Visibility = MiddleElement.Visibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;
78+
string announcement = MiddleElement.Visibility == Visibility.Visible ? "Element restored." : "Element repositioned.";
79+
UIHelper.AnnounceActionForAccessibility((UIElement)sender, announcement, "RepositionNotificationId");
7280
}
7381

7482
private void EntranceAddButton_Click(object sender, RoutedEventArgs e)
7583
{
76-
var value = Convert.ToInt32((sender as Button)?.Tag);
84+
int value = Convert.ToInt32((sender as Button)?.Tag);
7785

7886
for (int i = 0; i < value; i++)
7987
{
8088
Thickness thickness = new Thickness(5.0);
8189
EntranceStackPanel.Children.Add(new Rectangle() { Width = 50, Height = 50, Margin = thickness, Fill = new SolidColorBrush(Microsoft.UI.Colors.LightBlue) });
8290
}
91+
92+
string announcement = value == 1 ? "Added 1 rectangle." : $"Added {value} rectangles.";
93+
UIHelper.AnnounceActionForAccessibility((UIElement)sender, announcement, "EntranceAddNotificationId");
8394
}
8495

8596
private void EntranceClearButton_Click(object sender, RoutedEventArgs e)
8697
{
8798
EntranceStackPanel.Children.Clear();
99+
UIHelper.AnnounceActionForAccessibility((UIElement)sender, "All rectangles cleared.", "EntranceClearNotificationId");
88100
}
89101

90102
private void AddDeleteButton_Click(object sender, RoutedEventArgs e)
91103
{
92104
AddButton_Click(sender, e);
93105
DeleteButton_Click(sender, e);
106+
UIHelper.AnnounceActionForAccessibility((UIElement)sender, "Item added and item deleted.", "AddDeleteBothNotificationId");
94107
}
95108
}

0 commit comments

Comments
 (0)