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;
            }
        }
 private void Passwordbox_PasswordChanged(object sender, RoutedEventArgs e)
 {
     HasTextProperty.SetValue((PasswordBox)sender);
 }