@@ -68,7 +68,7 @@ public static Visibility GetDecorationVisibility(DependencyObject element)
6868 }
6969
7070 /// <summary>
71- /// Controls the visbility of the filled text field.
71+ /// Controls the visibility of the filled text field.
7272 /// </summary>
7373 public static readonly DependencyProperty HasFilledTextFieldProperty = DependencyProperty . RegisterAttached (
7474 "HasFilledTextField" , typeof ( bool ) , typeof ( TextFieldAssist ) , new PropertyMetadata ( false ) ) ;
@@ -116,7 +116,7 @@ public static CornerRadius GetTextFieldCornerRadius(DependencyObject element)
116116 }
117117
118118 /// <summary>
119- /// Controls the corner radius of the bottom line of the surroundig box.
119+ /// Controls the corner radius of the bottom line of the surrounding box.
120120 /// </summary>
121121 public static readonly DependencyProperty UnderlineCornerRadiusProperty = DependencyProperty . RegisterAttached (
122122 "UnderlineCornerRadius" , typeof ( CornerRadius ) , typeof ( TextFieldAssist ) , new PropertyMetadata ( new CornerRadius ( 0.0 ) ) ) ;
@@ -164,7 +164,7 @@ public static bool GetRippleOnFocusEnabled(DependencyObject element)
164164 }
165165
166166 /// <summary>
167- /// Automatially inserts spelling suggestions into the text box context menu.
167+ /// Automatically inserts spelling suggestions into the text box context menu.
168168 /// </summary>
169169 public static readonly DependencyProperty IncludeSpellingSuggestionsProperty = DependencyProperty . RegisterAttached (
170170 "IncludeSpellingSuggestions" , typeof ( bool ) , typeof ( TextFieldAssist ) , new PropertyMetadata ( default ( bool ) , IncludeSpellingSuggestionsChanged ) ) ;
@@ -181,8 +181,7 @@ public static bool GetIncludeSpellingSuggestions(TextBoxBase element)
181181
182182 private static void IncludeSpellingSuggestionsChanged ( DependencyObject element , DependencyPropertyChangedEventArgs e )
183183 {
184- var textBox = element as TextBoxBase ;
185- if ( textBox != null )
184+ if ( element is TextBoxBase textBox )
186185 {
187186 if ( ( bool ) e . NewValue )
188187 {
@@ -262,13 +261,12 @@ private static void TextBoxOnContextMenuOpening(object sender, ContextMenuEventA
262261
263262 private static SpellingError GetSpellingError ( TextBoxBase textBoxBase )
264263 {
265- var textBox = textBoxBase as TextBox ;
266- if ( textBox != null )
264+ if ( textBoxBase is TextBox textBox )
267265 {
268266 return textBox . GetSpellingError ( textBox . CaretIndex ) ;
269267 }
270- var richTextBox = textBoxBase as RichTextBox ;
271- if ( richTextBox != null )
268+
269+ if ( textBoxBase is RichTextBox richTextBox )
272270 {
273271 return richTextBox . GetSpellingError ( richTextBox . CaretPosition ) ;
274272 }
@@ -308,8 +306,7 @@ private static void ApplyTextBoxViewMargin(Control textBox, Thickness margin)
308306 return ;
309307 }
310308
311- var frameworkElement = ( textBox . Template . FindName ( "PART_ContentHost" , textBox ) as ScrollViewer ) ? . Content as FrameworkElement ;
312- if ( frameworkElement != null )
309+ if ( ( textBox . Template . FindName ( "PART_ContentHost" , textBox ) as ScrollViewer ) ? . Content is FrameworkElement frameworkElement )
313310 {
314311 frameworkElement . Margin = margin ;
315312 }
@@ -324,8 +321,7 @@ private static void TextBoxViewMarginPropertyChangedCallback(
324321 DependencyObject dependencyObject ,
325322 DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs )
326323 {
327- var box = dependencyObject as Control ; //could be a text box or password box
328- if ( box == null )
324+ if ( ! ( dependencyObject is Control box ) )
329325 {
330326 return ;
331327 }
0 commit comments