/// <summary> /// Handles changes to the AutoSelectOnFocus property. /// </summary> /// <param name="d"> /// The <see cref="DependencyObject"/> on which /// the property has changed value. /// </param> /// <param name="e"> /// Event data that is issued by any event that /// tracks changes to the effective value of this property. /// </param> private static void OnAutoSelectOnFocusChanged( DependencyObject d, DependencyPropertyChangedEventArgs e) { bool newAutoSelectOnFocus = (bool)d.GetValue(AutoSelectOnFocusProperty); var handler = GetPasswordAutoSelectOnFocusHandler(d); if (handler != null) { handler.Detach(); SetPasswordAutoSelectOnFocusHandler(d, null); } if (newAutoSelectOnFocus) { handler = new PasswordAutoSelectOnFocusHandler((PasswordBox)d); SetPasswordAutoSelectOnFocusHandler(d, handler); } }
public static void SetPasswordAutoSelectOnFocusHandler(DependencyObject d, PasswordAutoSelectOnFocusHandler value) { d.SetValue(PasswordAutoSelectOnFocusHandlerProperty, value); }