protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); // check if navigated from register, if so already fill in the registered e-mail if (e.Parameter is string && !e.Parameter.ToString().Equals("")) { EmailTextBox.Text = (string)e.Parameter; PasswordBox.Password = ""; RememberMe.IsChecked = false; } else { // automatic login if credential found (remember me was checked previously) var credential = GetCredential(); if (credential != null) { credential.RetrievePassword(); EmailTextBox.Text = credential.UserName; PasswordBox.Password = credential.Password; RememberMe.IsChecked = true; AttemptLogin(credential.UserName, credential.Password, true); } } EmailTextBox.Select(EmailTextBox.Text.Length, 0); // move cursor to end of textbox }
public Form1() { InitializeComponent(); EmailTextBox.Select(); }
public CreateAccount(IResolver resolver, CreateAccountViewModel viewModel) { InitializeComponent(); _resolver = resolver; _pbData = _resolver.GetInstanceOf <IPBData>(); _analytics = _resolver.GetInstanceOf <IInAppAnalytics>(); _owner = ((PBApp)Application.Current).FindWindow <LoginWindow>(); Loaded += OnLoaded; TitleGrid.MouseLeftButtonDown += OnTitleGridMouseLeftButtonDown; EmailTextBox.KeyDown += OnEmailTextBoxKeyDown; EmailTextBox.LostFocus += (o, e) => { if (_vm.IsEmailHasValue) { _vm.ValidateEmail(); } }; _vm = viewModel; DataContext = _vm; _vm.OnSubmit += (o, e) => { _vm.ValidateEmail(); SetTag(PasswordBoxObjectType.Master, _vm.IsValidMasterPassword); SetTag(PasswordBoxObjectType.Confirm, _vm.IsPasswordsEqual && _vm.IsValidMasterPassword); Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate() { if (!_vm.IsValidEmail) { EmailTextBox.Focus(); } else if (!_vm.IsValidMasterPassword) { _masterPasswordTextBox.Focus(); } else if (!_vm.IsPasswordsEqual) { _confirmPasswordTextBox.Focus(); } })); }; _vm.OnReset += (o, e) => { Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate() { _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsPasswordsEqual); _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsValidConfirmPassword); _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsConfirmPasswordHasValue); _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsEmailHasValue); _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsValidMasterPassword); _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsValidEmail); Clear(PasswordBoxObjectType.Master, true); Clear(PasswordBoxObjectType.Confirm, true); EmailTextBox.Focus(); Keyboard.Focus(EmailTextBox); EmailTextBox.Select(0, 0); })); }; _owner.Topmost = false; EmailTextBox.Focus(); }