public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var password = (sender as PasswordBox);

            if (!(sender is PasswordBox control))
            {
                return;
            }

            password.PasswordChanged -= Password_PasswordChanged;

            if ((bool)e.NewValue)
            {
                HasTextProperty.SetValue(password);
                password.PasswordChanged += Password_PasswordChanged;
            }
        }
 private static void Password_PasswordChanged(object sender, RoutedEventArgs e)
 {
     HasTextProperty.SetValue((PasswordBox)sender);
 }