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

3 posts, 1 answers
  1. Di
    Di avatar
    16 posts
    Member since:
    Jul 2013

    Posted 31 Jul 2013 Link to this post

    How can I hide it after the datetime is selected?

    Di.
  2. Answer
    Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 05 Aug 2013 Link to this post

    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 >>
  3. DevCraft banner
  4. Di
    Di avatar
    16 posts
    Member since:
    Jul 2013

    Posted 05 Aug 2013 Link to this post

    Thanks
Back to Top