예제 #1
0
        private void Box_PasswordChanged(object sender, RoutedEventArgs e)
        {
            PasswordBox box = sender as PasswordBox;

            box.SetValue(UpdatingProperty.ValueProperty, true);
            box.SetValue(BoundPasswordProperty.ValueProperty, box.Password);
            box.SetValue(UpdatingProperty.ValueProperty, false);

            HasPasswordProperty.SetValue(box);
        }
예제 #2
0
        public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            PasswordBox box = sender as PasswordBox;

            if (box == null)
            {
                return;
            }

            if ((bool)e.OldValue)
            {
                box.PasswordChanged -= Box_PasswordChanged;
            }

            if ((bool)e.NewValue)
            {
                box.PasswordChanged += Box_PasswordChanged;
                HasPasswordProperty.SetValue(box);
            }
        }