@@ -24,12 +24,42 @@ public ConfigurationWindow ()
2424 SquadronSystemComboBox . Text = config . squadronSystemName ;
2525 }
2626
27+ private void PhoneticNameTextBox_Loaded ( object sender , RoutedEventArgs e )
28+ {
29+ if ( sender is TextBox textBox )
30+ {
31+ // Force validation to reapply when the control is loaded
32+ var bindingExpression = textBox . GetBindingExpression ( TextBox . TextProperty ) ;
33+ if ( bindingExpression != null )
34+ {
35+ bindingExpression . UpdateSource ( ) ;
36+ // Explicitly refresh the validation state
37+ var errors = Validation . GetErrors ( textBox ) ;
38+ if ( errors . Count > 0 )
39+ {
40+ Validation . ClearInvalid ( bindingExpression ) ;
41+ Validation . MarkInvalid ( bindingExpression , errors [ 0 ] ) ;
42+ }
43+ else
44+ {
45+ Validation . ClearInvalid ( bindingExpression ) ;
46+ }
47+ // Force WPF to refresh the visual state
48+ textBox . InvalidateVisual ( ) ;
49+ textBox . UpdateLayout ( ) ;
50+ }
51+ }
52+ }
53+
2754 private void PhoneticName_TextChanged ( object sender , TextChangedEventArgs e )
2855 {
29- // Replace any spaces, maintaining the original caret position
30- var caretIndex = phoneticNameTextBox . CaretIndex ;
31- phoneticNameTextBox . Text = phoneticNameTextBox . Text . Replace ( " " , "ˈ" ) ;
32- phoneticNameTextBox . CaretIndex = Math . Max ( caretIndex , phoneticNameTextBox . Text . Length ) ;
56+ if ( sender is TextBox textBox )
57+ {
58+ // Replace any spaces, maintaining the original caret position
59+ var caretIndex = textBox . CaretIndex ;
60+ textBox . Text = textBox . Text . Replace ( " " , "ˈ" ) ;
61+ textBox . CaretIndex = Math . Max ( caretIndex , textBox . Text . Length ) ;
62+ }
3363 }
3464
3565 private void phoneticNameTestButtonClicked ( object sender , RoutedEventArgs e )
0 commit comments