private void ApplicationBarSignInButtonClicked(object sender, EventArgs e) { var focusedElement = (FrameworkElement)FocusManager.GetFocusedElement(); AppBarBindingsHelper.UpdateBinding(focusedElement); var viewModel = (LoginViewModel)DataContext; viewModel.SignInCommand.Execute(null); }
private static void FilterEnterKeysAndForwardToCommand(object sender, KeyEventArgs e) { var attachedElement = sender as TextBox; if (e.Key == Key.Enter) { AppBarBindingsHelper.UpdateBinding(attachedElement); // If ony the enter key was pressed var command = GetCommand(attachedElement); var commandParameter = GetCommandParameter(attachedElement); command.Execute(commandParameter); if (GetHideKeyboardAfterEnter(attachedElement)) { GetControlToFocusAfterEnter(attachedElement).Focus(); } } }