void OnLoaded(object sender, RoutedEventArgs e) { Dispatcher.BeginInvoke(new Action(() => { UpdateButtonState(); foreach (UIElement child in EntryPanel.Children) { TextBox box = child as TextBox; if (box != null && box.Visibility == System.Windows.Visibility.Visible) { box.Focus(); box.SelectAll(); break; } else { PasswordControl pswd = child as PasswordControl; if (pswd != null && pswd.Visibility == System.Windows.Visibility.Visible) { pswd.SelectAll(); break; } } } })); }
private void OnPasswordBoxGotFocus(object sender, RoutedEventArgs e) { PasswordControl box = (PasswordControl)sender; box.SelectAll(); }