private async void SendButton_Click(object sender, RoutedEventArgs e) { SendButton.IsEnabled = false; SendButton.Focus(); var result = await PostApi.AddComment( SettingsManager.PersistentSettings.CurrentUser.Token, PostId, ContentTextBox.Text, IsAnonymous) .ConfigureAwait(true); if (result.IsError) { await DialogManager.ShowErrorDialog(result.Message) .ConfigureAwait(true); SendButton.IsEnabled = true; return; } ContentTextBox.Text = string.Empty; RaiseEvent(new RoutedEventArgs(CommentAddEvent)); ContentTextBox.Focus(); SendButton.IsEnabled = true; }
private void TextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && e.KeyboardDevice.Modifiers == ModifierKeys.None) { SendButton.Focus(); ((ChatViewModel)SendButton.DataContext).SendCommand.Execute(null); ((TextBox)sender).Focus(); } }
private void ContentTextBox_KeyUp(object sender, KeyEventArgs e) { if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control) && e.Key == Key.Enter) { if (SendButton.IsEnabled) { SendButton.Focus(); SendButton_Click(this, new RoutedEventArgs()); } } }