protected override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            // Get the caller
            var passwordBox = sender as PasswordBox;

            // Make sure it is a password box
            if (passwordBox == null)
            {
                return;
            }

            // Remove any previous events
            passwordBox.PasswordChanged -= PasswordBox_PasswordChanged;

            // If the caller set MonitorPassword to true...
            if ((Boolean)e.NewValue)
            {
                // Set default value
                HasTextProperty.SetValue(passwordBox);
                // Start listening out for password changes
                passwordBox.PasswordChanged += PasswordBox_PasswordChanged;
            }
        }
 private void PasswordBox_PasswordChanged(Object sender, RoutedEventArgs e)
 {
     // Set the attached HasText value
     HasTextProperty.SetValue((PasswordBox)sender);
 }