FZE: Fix dialog number box input automation name (#12718)

This commit is contained in:
Jaime Bernardo
2021-08-12 14:17:44 +01:00
committed by GitHub
parent d704aad162
commit 7f7ab5f5b1
2 changed files with 13 additions and 0 deletions

View File

@@ -480,6 +480,7 @@
KeyDown="EditDialogNumberBox_KeyDown"
Margin="12,0,0,0"
Header="{x:Static props:Resources.Number_of_zones}"
Loaded="NumberBox_Loaded"
AutomationProperties.Name="{x:Static props:Resources.Number_of_zones}"
SpinButtonPlacementMode="Compact"
Text="{Binding TemplateZoneCount}" />
@@ -508,6 +509,7 @@
SpinButtonPlacementMode="Compact"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Loaded="NumberBox_Loaded"
AutomationProperties.Name="{x:Static props:Resources.Space_Around_Zones}"
AutomationProperties.LabeledBy="{Binding ElementName=spacingTitle}" />
<TextBlock Text="{x:Static props:Resources.Pixels}"
@@ -554,6 +556,7 @@
Maximum="1000"
KeyDown="EditDialogNumberBox_KeyDown"
Margin="12,0,0,0"
Loaded="NumberBox_Loaded"
AutomationProperties.Name="{x:Static props:Resources.Distance_adjacent_zones}"
AutomationProperties.LabeledBy="{Binding ElementName=distanceTitle}"
SpinButtonPlacementMode="Compact"

View File

@@ -491,5 +491,15 @@ namespace FancyZonesEditor
_backup = null;
}
}
private void NumberBox_Loaded(object sender, RoutedEventArgs e)
{
// The TextBox inside a NumberBox doesn't inherit the Automation Properties name, so we have to set it.
var numberBox = sender as NumberBox;
const string numberBoxTextBoxName = "InputBox"; // Text box template part name given by ModernWPF.
numberBox.ApplyTemplate(); // Apply template to be able to change child's property.
var numberBoxTextBox = numberBox.Template.FindName(numberBoxTextBoxName, numberBox) as TextBox;
numberBoxTextBox.SetValue(AutomationProperties.NameProperty, numberBox.GetValue(AutomationProperties.NameProperty));
}
}
}