This question is locked. New answers and comments are not allowed.
Hi.
When you select a time from the selection box is possible to auto-close? At the moment you have to select the icon again for the calendar to be removed.
Thanks P
When you select a time from the selection box is possible to auto-close? At the moment you have to select the icon again for the calendar to be removed.
Thanks P
5 Answers, 1 is accepted
0
Hi Paul,
Best wishes,
Miroslav Nedyalkov
the Telerik team
Currently the DateTimePicker control closes its popup when value is selected with the mouse only if it its InputMode is DatePicker or TimePicker. If you want to change this behavior you need to handle the DateTimeSelectedWithMouseEvent routed event of the RadDateTimePicker control (it is not exposed as a CLR event, but you can still handle it). Here is our current code that closes the DateTimePicker drop-down. What you will need to do is similar:
EventManager.RegisterClassHandler(
typeof
(RadDateTimePicker), RadDateTimePicker.DateTimeSelectedWithMouseEvent,
new
RoutedEventHandler(OnDateTimeSelectedWithMouse));
private
static
void
OnDateTimeSelectedWithMouse(
object
sender, RoutedEventArgs args)
{
var picker = sender
as
RadDateTimePicker;
// If the picker is not a DateTimePicker and the drop-down is opened than close it.
if
(picker !=
null
&& picker.InputMode != InputMode.DateTimePicker && picker.IsDropDownOpen)
{
picker.IsDropDownOpen =
false
;
}
}
Miroslav Nedyalkov
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0

Simon
Top achievements
Rank 1
answered on 21 Feb 2012, 11:31 PM
Hi Miroslav,
We have a DateTimePicker where the inputmode is DateTimePicker. However we only want to close the dropdown when the Time is selected. You solution does not cater for this.
Can you propose a way to do this using your DateTimeSelectedWithMouseEvent. We just need to test that the Time portion of the control has been selected.
Thanks
Simon
We have a DateTimePicker where the inputmode is DateTimePicker. However we only want to close the dropdown when the Time is selected. You solution does not cater for this.
Can you propose a way to do this using your DateTimeSelectedWithMouseEvent. We just need to test that the Time portion of the control has been selected.
Thanks
Simon
0
Hello,
The idea is to identify which control was actually clicked - the calendar or the clock and if the clock is clicked, than close the drop down.
Hope this helps. Regards,
Miroslav Nedyalkov
the Telerik team
What I would suggest you is to change the code in the event handler with the following:
var picker = sender
as
RadDateTimePicker;
// If the picker is not a DateTimePicker and the drop-down is opened than close it.
if
(picker !=
null
&& picker.IsDropDownOpen && ((RadRoutedEventArgs)args).Source
is
RadClock)
{
picker.IsDropDownOpen =
false
;
}
The idea is to identify which control was actually clicked - the calendar or the clock and if the clock is clicked, than close the drop down.
Hope this helps. Regards,
Miroslav Nedyalkov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
1

Talal
Top achievements
Rank 1
answered on 31 Jan 2013, 12:12 PM
I succeeded with auto close in case of time input section selected. Using this
EventManager.RegisterClassHandler(
typeof
(RadDateTimePicker), RadDateTimePicker.DateTimeSelectedWithMouseEvent,
new
RoutedEventHandler(OnDateTimeSelectedWithMouse));
private
static
void
OnDateTimeSelectedWithMouse(
object
sender, RoutedEventArgs args)
{
var picker = sender
as
RadDateTimePicker;
// If the picker is a DateTimePicker and the drop-down is opened than close it if mouse down on time selection.
if
(picker !=
null
&& picker.InputMode == InputMode.DateTimePicker && picker.IsDropDownOpen &&(args).OriginalSource is RadClock)
{
picker.IsDropDownOpen =
false
;
}
}
0

Ad
Top achievements
Rank 2
answered on 09 Mar 2015, 12:11 PM
I implemented a custom 'Today' button using my own style, and I had the same problem: the DateTimePicker does not close automatically after pressing 'Today' (while this works perfect when clicking any Date in the DateTimePicker).
Now I'm using the fix described above, and it works like a charm:
private void DatePicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ViewModel.CurrentPeriodChangeInfo.CurrentDate = DateTimePicker.DisplayDate;
DateTimePicker.IsDropDownOpen = false;
}
Now I'm using the fix described above, and it works like a charm:
private void DatePicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ViewModel.CurrentPeriodChangeInfo.CurrentDate = DateTimePicker.DisplayDate;
DateTimePicker.IsDropDownOpen = false;
}