bool checkSetting(bool result, PasswordBox passwordBox, string message) { if (!result) { MessageBox.Show(message, resources["Connect"] as string, MessageBoxButton.OK, MessageBoxImage.Warning); passwordBox.SelectAll(); passwordBox.Focus(); } return result; }
private void SetSelection(PasswordBox passwordBox, int start, int length) { try { if (start < 0x0) { start = passwordBox.Password.Length; } passwordBox.GetType().GetMethod("Select", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(passwordBox, new object[] { start, length }); } catch (Exception exception) { DebugLog.Assert(false, exception.Message); passwordBox.SelectAll(); } }
public static void bindTextBox(PasswordBox passwordBox, string name) { passwordBox.Password = settings[name] as string; passwordBox.PasswordChanged += (sender, e) => { settings[name] = passwordBox.Password; }; passwordBox.GotFocus += (sender, e) => { passwordBox.SelectAll(); }; }
public static void bindTextBox(PasswordBox passwordBox, string name) { passwordBox.Password = settings[name] as string; passwordBox.PasswordChanged += (sender, e) => { var password = passwordBox.Password; if (settings[name] as string != password) { settings[name] = password; } }; settings.PropertyChanged += (sender, e) => { if (e.PropertyName == name) { var password = settings[name] as string; if (passwordBox.Password != password) { passwordBox.Password = password; } } }; passwordBox.GotFocus += (sender, e) => { passwordBox.SelectAll(); }; }