Approved
Last Updated: 23 Jan 2018 07:46 by ADMIN
ADMIN
Dinko
Created on: 23 Jan 2018 07:31
Category: DateTimePicker
Type: Bug Report
2
DateTimePicker: SelectedTime property is not updated correctly when InputMode is set to TimePicker
When the SelectedValue property of the RadDateTimePicker controls is bound to a TimeSpan (10:13) and such time does not exist in the drop down, the SelectedTime property is set to null.

As a workaround, you can subscribe to the DropDownOpened and SelectionChanged events. In the DropDownOpened event handler, you can get the current time using the SelectedTime property. Then in the SelectionChanged event handler, you can set the preserved value to the SelectedTime property of the RadDateTimePicker. 

public partial class MainPage : UserControl
{
	private bool IsLoadedFirstTime = true;
	private TimeSpan? SelectedTime;
	public MainPage()
	{
		InitializeComponent();
		this.DataContext = new MainViewModel();
	}

	private void StartDatePicker_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
	{
		var control = sender as RadDateTimePicker;
		if(IsLoadedFirstTime && control.IsDropDownOpen)
		{
			control.SelectedTime = SelectedTime;
			IsLoadedFirstTime = false;
		}          
	}

	private void StartDatePicker_DropDownOpened(object sender, System.Windows.RoutedEventArgs e)
	{
		var control = sender as RadDateTimePicker;
		if(IsLoadedFirstTime )
		{
			SelectedTime = control.SelectedTime as TimeSpan?;
		}
	}
}
0 comments