コード例 #1
0
        private void ApplicationBarSignInButtonClicked(object sender, EventArgs e)
        {
            var focusedElement = (FrameworkElement)FocusManager.GetFocusedElement();

            AppBarBindingsHelper.UpdateBinding(focusedElement);

            var viewModel = (LoginViewModel)DataContext;

            viewModel.SignInCommand.Execute(null);
        }
コード例 #2
0
        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();
                }
            }
        }