public override void onValueChange(DependencyObject d, DependencyPropertyChangedEventArgs e) { //Getting the password object from the calles var passwordBox = (d as PasswordBox); //Checking for safty if (passwordBox == null) { return; } //Clear Previous events passwordBox.PasswordChanged += PasswordBox_PasswordChanged; //If calles monitorPassword is true.. if ((bool)e.NewValue) { //Sets the default value HasTextProperty.SetValue(passwordBox); //Listiens to value changed event passwordBox.PasswordChanged += PasswordBox_PasswordChanged; } }
/// <summary> /// The event that will trigger when the passwordbox.password changes /// </summary> /// <param name="sender">The passwordBox</param> /// <param name="e"></param> private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) { HasTextProperty.SetValue((sender as PasswordBox)); }