public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var passwordBox = sender as PasswordBox; if (passwordBox == null) { return; } passwordBox.PasswordChanged -= PasswordBox_PasswordChanged; if ((bool)e.NewValue) { HasTextProperty.SetValue(passwordBox); passwordBox.PasswordChanged += PasswordBox_PasswordChanged; } }
/// <summary> /// Fired when the password box password value changes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) { // Set the attaached HasText value HasTextProperty.SetValue((PasswordBox)sender); }