private void Tx_search_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter || e.Key == Key.F8) { BtnBuscar.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); } }
private void TxtShear_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { this.Close(); e.Handled = true; } if (e.Key == Key.Enter) { BtnBuscar.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); e.Handled = true; } if (e.Key == Key.Down) { if (dataGrid.Items.Count == 0) { return; } dataGrid.Focus(); var uiElement = e.OriginalSource as UIElement; dataGrid.SelectedItem = dataGrid.Items[0]; uiElement.MoveFocus(new TraversalRequest(FocusNavigationDirection.Down)); dataGrid.CurrentCell = new DataGridCellInfo(dataGrid.Items[dataGrid.SelectedIndex], dataGrid.Columns[0]); dataGrid.CommitEdit(); dataGrid.SelectedIndex = dataGrid.SelectedIndex; e.Handled = true; } }