Posted 13 December 2020, 11:21 pm EST
Hi Mayur,
Generally, it is not expected to use the Up/Down keys for navigating dates in a DatePicker. Therefore, you have to use the C1MaskedTextBox’s (present in C1DatePicker template) PreviewKeyDown event to handle the Up/down keys.
For example, you can increment/decrement the date by 1 day using Up/Down keys as follows:
private void MaskedTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
if ((e.Key == Key.Up || e.Key == Key.Down) && datePicker.SelectedDate.HasValue)
{
e.Handled = true;
switch (e.Key)
{
case Key.Up:
datePicker.Increment(TimeSpan.FromDays(1));
break;
case Key.Down:
datePicker.Decrement(TimeSpan.FromDays(1));
break;
}
}
}
Just in case required, you can use arrow keys in the Calendar present in the C1DatePicker’s DropDown.
Please refer to the same from the attached sample. (see DatePickerUpDownKeys.zip)
Regards,
Kartik
DatePickerUpDownKeys.zip