private static void SelectAllOnKeyboardFocus_PropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { var TextBoxBase = o as TextBoxBase; if (TextBoxBase == null) { throw new ArgumentException("Type mismatch", "o"); } var Value = (bool)e.NewValue; var Listener = GetSelectAllOnKeyboardFocusWeakEventListener(TextBoxBase); if (Value) { if (Listener == null) { Listener = new SelectAllOnKeyboardFocusEventListener(); } SetSelectAllOnKeyboardFocusWeakEventListener(TextBoxBase, Listener); GotKeyboardFocusEventManager.AddListener(TextBoxBase, Listener); } else if (Listener != null) { SetSelectAllOnKeyboardFocusWeakEventListener(TextBoxBase, null); GotKeyboardFocusEventManager.RemoveListener(TextBoxBase, Listener); } }
private static void SelectAllOnKeyboardFocus_PropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { var TextBoxBase = o as TextBoxBase; if (TextBoxBase == null) throw new ArgumentException("Type mismatch", "o"); var Value = (bool)e.NewValue; var Listener = GetSelectAllOnKeyboardFocusWeakEventListener(TextBoxBase); if (Value) { if (Listener == null) Listener = new SelectAllOnKeyboardFocusEventListener(); SetSelectAllOnKeyboardFocusWeakEventListener(TextBoxBase, Listener); GotKeyboardFocusEventManager.AddListener(TextBoxBase, Listener); } else if (Listener != null) { SetSelectAllOnKeyboardFocusWeakEventListener(TextBoxBase, null); GotKeyboardFocusEventManager.RemoveListener(TextBoxBase, Listener); } }