In the date selector, the tab key should select the date and move the focus to the next field. Currently tab moves to the next day of the month in the date selector and keeps the date selector open as focus on Calendar control instead of Date Picker.
I have created custom DatePicker control which has been inherited by RadDatePicker. In DropDownOpened event, I have set Today's date, if Selected value=null and on KeyUp event, I want to move to the next control, if user has pressed Tab/Escape event. Esc is going to work. But in case of Tab KeyUp, it is not going into the KeyUp event (as focus is on Calendar control). I want to get Calendar control's object and on its KeyUp event, I want to close calendar and I want to move on next control.
Let me know what to do.
Here I have paste my custom control.
public class CDatePicker : RadDatePicker
{
#region Constructor
public CDatePicker()
: base()
{
this.DateTimeWatermarkContent = string.Empty;
this.DropDownOpened += new RoutedEventHandler(CDatePicker_DropDownOpened);
}
#endregion
#region Events
protected override void OnKeyDown(KeyEventArgs e)
{
if (this.IsDropDownOpen)
{
if (e.Key == Key.Escape)
{
this.IsDropDownOpen = false;
}
if (e.Key == Key.Tab)
{
this.IsDropDownOpen = false;
}
}
base.OnKeyDown(e);
}
void CDatePicker_DropDownOpened(object sender, RoutedEventArgs e)
{
if (this.SelectedDate == null)
{
this.SelectedValue = DateTime.Now.Date;
}
}
#endregion
}