public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { PasswordBox passwordBox = sender as PasswordBox; if (passwordBox == null) { return; } passwordBox.PasswordChanged -= PasswordBox_PasswordChanged; if ((bool)e.NewValue) { HasTextProperty.SetValue(passwordBox); passwordBox.PasswordChanged += PasswordBox_PasswordChanged; } }
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { //Get the caller var passwordBox = sender as PasswordBox; if (passwordBox == null) { return; } //Remove previos events passwordBox.PasswordChanged -= PasswordBox_PasswordChanged; //If the caller set MonitorPassword to true... if ((bool)e.NewValue) { //Set the default value HasTextProperty.SetValue(passwordBox); //start listening for password changes passwordBox.PasswordChanged += PasswordBox_PasswordChanged; } }
public 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; } passwordBox.PasswordChanged -= PasswordBox_PasswordChanged; // If the caller set MonitorPassword to true.. if ((bool)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) { HasTextProperty.SetValue((PasswordBox)sender); }
/// <summary> /// Fired when the password box password valuye 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); }