private void cmbYear_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { SetToday(); } else if (e.Key == Key.Delete) { Date = ""; } else if (e.Key == Key.Escape) { cmbYear.SelectedIndex = Years.IndexOf(year.ToString()); } }
//public delegate void MyEvent(); //public event MyEvent DateChanged; private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { try { var parts = TextBox.Text.Split('/').Select(int.Parse).ToArray(); //year = parts[0]; //month = parts[1]; //day = parts[2]; cmbYear.SelectedIndex = Years.IndexOf(parts[0].ToString()); cmbMonth.SelectedIndex = parts[1] - 1; cmbDay.SelectedIndex = parts[2] - 1; } catch (Exception) { } }