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

            //Make sure it's a passwordBox
            if (passwordBox == null)
            {
                return;
            }

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

            //If the caller set monitorPassword to true
            if ((bool)e.NewValue)
            {
                //set default vlaue
                HasTextProperty.SetValue(passwordBox);
                //Start listening out for password changes
                passwordBox.PasswordChanged += PasswordBox_PasswordChanged;
            }
        }
Exemple #2
0
 /// <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 attached HasText value
     HasTextProperty.SetValue((PasswordBox)sender);
 }