コード例 #1
0
        private static void OnBoundPasswordChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var passwordBox = d as PasswordBox;

            // only handle this event when the property is attached to a PasswordBox
            // and when the BindPassword attached property has been set to true
            if (passwordBox == null || !GetBindPassword(d))
            {
                return;
            }

            // avoid recursive updating by ignoring the box's changed event
            passwordBox.PasswordChanged -= HandlePasswordChanged;

            var newPasswordSecure = (SecureString)e.NewValue;
            var newPassword       = newPasswordSecure.ToInsecureString();

            if (!GetUpdatingPassword(passwordBox))
            {
                passwordBox.Password = newPassword;
                if (!string.IsNullOrWhiteSpace(newPassword))
                {
                    TextboxHelper.SetWatermark(passwordBox, "");
                }
            }

            passwordBox.PasswordChanged += HandlePasswordChanged;
        }
コード例 #2
0
 private static void configureWaterMark(TextBox d, string value)
 {
     TextboxHelper.SetWatermark(d, value);
 }