Skip to content

Commit 2b68976

Browse files
authored
feat(accessibility): add accessibility labels to tweaks ui (ChrisTitusTech#3731)
1 parent 5369d9d commit 2b68976

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

functions/public/Invoke-WPFUIElements.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ function Invoke-WPFUIElements {
156156
$checkBox.Name = $entryInfo.Name
157157
$checkBox.HorizontalAlignment = "Right"
158158
$checkBox.UseLayoutRounding = $true
159+
[System.Windows.Automation.AutomationProperties]::SetName($checkBox, $entryInfo.Content)
159160
$dockPanel.Children.Add($checkBox) | Out-Null
160161
$checkBox.Style = $ColorfulToggleSwitchStyle
161162

@@ -191,6 +192,7 @@ function Invoke-WPFUIElements {
191192
$toggleButton.ToolTip = $entryInfo.Description
192193
$toggleButton.HorizontalAlignment = "Left"
193194
$toggleButton.Style = $ToggleButtonStyle
195+
[System.Windows.Automation.AutomationProperties]::SetName($toggleButton, $entryInfo.Content[0])
194196

195197
$toggleButton.Tag = @{
196198
contentOn = if ($entryInfo.Content.Count -ge 1) { $entryInfo.Content[0] } else { "" }
@@ -232,6 +234,7 @@ function Invoke-WPFUIElements {
232234
$comboBox.SetResourceReference([Windows.Controls.Control]::MarginProperty, "ButtonMargin")
233235
$comboBox.SetResourceReference([Windows.Controls.Control]::FontSizeProperty, "ButtonFontSize")
234236
$comboBox.UseLayoutRounding = $true
237+
[System.Windows.Automation.AutomationProperties]::SetName($comboBox, $entryInfo.Content)
235238

236239
foreach ($comboitem in ($entryInfo.ComboItems -split " ")) {
237240
$comboBoxItem = New-Object Windows.Controls.ComboBoxItem
@@ -273,6 +276,7 @@ function Invoke-WPFUIElements {
273276
$baseWidth = [int]$entryInfo.ButtonWidth
274277
$button.Width = [math]::Max($baseWidth, 350)
275278
}
279+
[System.Windows.Automation.AutomationProperties]::SetName($button, $entryInfo.Content)
276280
$itemsControl.Items.Add($button) | Out-Null
277281

278282
$sync[$entryInfo.Name] = $button
@@ -303,6 +307,7 @@ function Invoke-WPFUIElements {
303307
$radioButton.SetResourceReference([Windows.Controls.Control]::FontSizeProperty, "ButtonFontSize")
304308
$radioButton.ToolTip = $entryInfo.Description
305309
$radioButton.UseLayoutRounding = $true
310+
[System.Windows.Automation.AutomationProperties]::SetName($radioButton, $entryInfo.Content)
306311

307312
if ($entryInfo.Checked -eq $true) {
308313
$radioButton.IsChecked = $true
@@ -324,6 +329,7 @@ function Invoke-WPFUIElements {
324329
$checkBox.ToolTip = $entryInfo.Description
325330
$checkBox.SetResourceReference([Windows.Controls.Control]::MarginProperty, "CheckBoxMargin")
326331
$checkBox.UseLayoutRounding = $true
332+
[System.Windows.Automation.AutomationProperties]::SetName($checkBox, $entryInfo.Content)
327333
if ($entryInfo.Checked -eq $true) {
328334
$checkBox.IsChecked = $entryInfo.Checked
329335
}

0 commit comments

Comments
 (0)