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

RadDateTimePicker SelectedValue does not change when user clears input

2 Answers 308 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 09 Jun 2011, 01:23 PM
I have a RadDateTimePicker control in a view that is bound to a datetime property in the associated viewmodel using the SelectedValue of the RadDateTimePicker. When the user selects a date and / or time, the datetime property in the viewmodel is set accordingly. However, if the user subsequently clears the input and the default 'Enter date' text is displayed in the control, the datetime property in the viewmodel is not set to null / mindatetime.

How can I implement the RadDateTimePicker so that if a user clears the datetime from the control the SelectedValue becomes null or mindatetime?

2 Answers, 1 is accepted

Sort by
0
Thomas
Top achievements
Rank 1
answered on 10 Jun 2011, 09:09 AM
I have managed to handle this by also binding a property in the viewmodel to the DateTimeText property of the control and checking for blank. it is a bit of a pain having to do this. Please can we have it so that RadDateTimePicker SelectedValue becomes null when user clears input from the control.
0
Yana
Telerik team
answered on 14 Jun 2011, 02:43 PM
Hello Thomas,

You should define the DateTime property in the View-Model like this:

private DateTime? selectedDate;
 
public DateTime? SelectedDate
{
    set { this.selectedDate = value; }
    get  {return this.selectedDate; }
}

and then bind it to the DateTimePicker:

<telerikInput:RadDateTimePicker SelectedValue="{Binding SelectedDate, Mode=TwoWay}"/>

Please try it and let us know the result.

All the best,
Yana
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
Tags
DateTimePicker
Asked by
Thomas
Top achievements
Rank 1
Answers by
Thomas
Top achievements
Rank 1
Yana
Telerik team
Share this question
or