Ejemplo n.º 1
0
        public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            if (!(sender is PasswordBox passwordBox))
            {
                return;
            }

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

            // If the caller set MonitorPassword to true...
            if ((bool)e.NewValue)
            {
                // Set default value
                HasTextProperty.SetValue(passwordBox);

                // Start listining out for password changes
                passwordBox.PasswordChanged += PasswordBox_PasswordChanged;
            }
        }
Ejemplo n.º 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)
 {
     HasTextProperty.SetValue((PasswordBox)sender);
 }