This is a migrated thread and some comments may be shown as answers.

Why the RadDateTimePicker's calendar isn't hiding after the datetime is selected?

2 Answers 160 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Di
Top achievements
Rank 1
Di asked on 31 Jul 2013, 07:11 PM
How can I hide it after the datetime is selected?

Di.

2 Answers, 1 is accepted

Sort by
0
Accepted
Vladi
Telerik team
answered on 05 Aug 2013, 11:00 AM
Hello,

The reason for the DropDown portion of the DateTimePicker not getting closed when selection is made is because unlike the DatePicker/TimePicker controls there are multiple parts of the DateTime object that could be selected. When using DateTimePicker you could select a date from the calendar and select a time from the clock part of the control. In this case if the DropDown is closed after only one selection you will need to open it twice to be able to select the full date and time.

Achieving the desired behavior is easily achievable with the use of the SelectionChanged event. In that event you will need to:
  1. Check if new items (new selection) have been added with the use of the SelectionChangedEventArgs
  2. If the previous condition is true set the IsDropDownOpen of the RadDateTimePicker control to false.

the next code snippet shows the previous approach:

<telerik:RadDateTimePicker SelectionChanged="RadDateTimePicker_SelectionChanged"/>

and in the code behind:
private void RadDateTimePicker_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
{
    if (e.AddedItems != null)
    {
        var dateTimePicker = sender as RadDateTimePicker;
        dateTimePicker.IsDropDownOpen = false;
    }
}

Hope this is helpful.
Regards,
Vladi
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Di
Top achievements
Rank 1
answered on 05 Aug 2013, 12:46 PM
Thanks
Tags
DateTimePicker
Asked by
Di
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Di
Top achievements
Rank 1
Share this question
or