/// <summary> /// fires when the passwordBox password values changes /// </summary> /// <param name="sender"> the ui element that has property changed</param> /// <param name="e">event args</param> private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) { //set the attached HasText Value HasTextProperty.SetValue((PasswordBox)sender); //set the BoundPassword Property BoundPasswordProperty.SetValue((PasswordBox)sender); }
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { //get the caller var passwordBox = sender as PasswordBox; if (passwordBox == null) { return; } //remove any previous event listener passwordBox.PasswordChanged -= PasswordBox_PasswordChanged; //if the caller set Monitor to true if ((bool)e.NewValue) { // set default value HasTextProperty.SetValue(passwordBox); passwordBox.PasswordChanged += PasswordBox_PasswordChanged; } }