RadDateTimePicker SelectedValue does not change when user clears input

3 posts, 0 answers
  1. Thomas
    Thomas avatar
    2 posts
    Member since:
    Jun 2011

    Posted 09 Jun 2011 Link to this post

    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. Thomas
    Thomas avatar
    2 posts
    Member since:
    Jun 2011

    Posted 10 Jun 2011 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 14 Jun 2011 Link to this post

    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
Back to Top