public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { if (!(sender is PasswordBox passwordBox)) { return; } passwordBox.PasswordChanged -= this.PasswordBox_PasswordChanged; if ((bool)e.NewValue) { HasTextProperty.SetValue(passwordBox); passwordBox.PasswordChanged += this.PasswordBox_PasswordChanged; } }
public override void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var passwordBox = d as PasswordBox; if (passwordBox == null) { return; } passwordBox.PasswordChanged -= this.PasswordBox_PasswordChanged; if ((bool)e.NewValue) { HasTextProperty.SetValue(passwordBox); passwordBox.PasswordChanged += this.PasswordBox_PasswordChanged; } }
public override void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { // Make sure it is a password box if (!(d is PasswordBox passwordBox)) { return; } // Remove any previous events 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 changed passwordBox.PasswordChanged += PasswordBox_PasswordChanged; } }
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { PasswordBox passwordBox = sender as PasswordBox; // make sure its a password box 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 value HasTextProperty.SetValue(sender); passwordBox.PasswordChanged += PasswordBox_PasswordChanged; } }
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { //get caller var passwordBox = sender as PasswordBox; //make sure it is passwordBox if (passwordBox == null) { return; } //remove previous events passwordBox.PasswordChanged -= PasswordBox_PasswordChanged; //if true listen out if ((bool)e.NewValue) { //set default value HasTextProperty.SetValue(passwordBox); 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; } //remove any previous events 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; } }
/// <summary> /// Override the OnValueChanged base function to check if the <see cref="PasswordBox"/> text /// has changed /// </summary> /// <param name="sender">The PasswordBox to check</param> /// <param name="e">The event arguments</param> public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { // Get the caller var passwordBox = (PasswordBox)sender; // Make sure we are using a PasswordBox if (passwordBox == null) { return; } // Remove any previous events passwordBox.PasswordChanged -= PasswordBox_PasswordChanged; // If the caller set MonitorPassword to true, start listening for an event if ((bool)e.NewValue) { // Set default value HasTextProperty.SetValue(passwordBox); // Start listening for password changes passwordBox.PasswordChanged += PasswordBox_PasswordChanged; } }
/// <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); }
/// <summary> /// Fire when the password box password changes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) { HasTextProperty.SetValue((PasswordBox)sender); }