private void Ventana_Loaded(object sender, RoutedEventArgs e) { // Ponemos el foco en el inicio. if (TbInicio.Text != "") { TbLinea.Focus(); } else { TbInicio.Focus(); } }
private void Tb_KeyDown(object sender, KeyEventArgs e) { // Si pulsamos Enter, actuamos, según sea el textbox que ha producido el evento. if (e.Key == Key.Enter) { TextBox tb = (TextBox)sender; if (tb == TbNumero) { if (ChDeducirTurno.IsChecked == true) { TbValoracion.Focus(); } else { TbTurno.Focus(); } e.Handled = true; } else if (tb == TbTurno) { TbValoracion.Focus(); e.Handled = true; } else if (tb == TbValoracion) { TbInicio.Focus(); e.Handled = true; } else if (tb == TbInicio) { TbFinal.Focus(); e.Handled = true; } else if (tb == TbFinal) { if (TbInicioPartido.IsVisible) { TbInicioPartido.Focus(); e.Handled = true; } } else if (tb == TbInicioPartido) { TbFinalPartido.Focus(); e.Handled = true; } } }