public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { if (!(sender is PasswordBox passwordBox)) { return; } passwordBox.PasswordChanged -= PasswordChanged; if (!(bool)e.NewValue) { return; } HasTextProperty.SetValue(passwordBox); passwordBox.PasswordChanged += PasswordChanged; }
private static void PasswordChanged(object sender, RoutedEventArgs e) { HasTextProperty.SetValue((PasswordBox)sender); }