Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > DatePicker > Restore a default date when InputBox is blank

Answered Restore a default date when InputBox is blank

Feed from this thread
  • Olena avatar

    Posted on Nov 17, 2011 (permalink)

    Hello Telerik
    I need to restore (some) default date in InputBox after user has blanked input. I have solved this task by binding SelectedValue-property to an Date object, implementing PropertyChanged event of the INotifyPropertyChanged interface and adding a Handler for LostFocus event. This approach works but I wonder if there is a better and smarter solution(solutions).
    Thanks in advance.
    Best regards\ Olena.

    Reply

  • Answer Ivo Ivo admin's avatar

    Posted on Nov 22, 2011 (permalink)

    Hello Olena,

    I do not think you need to add handler for the LostFocus event of RadDatePicker. This is how I managed to implement it:
    private DateTime? selectedDate;
     
    public DateTime? SelectedDate
    {
        get
        {
            var value = this.selectedDate == null ? DateTime.Today : (DateTime)this.selectedDate;
            return value;
        }
        set
        {
            var val = value == null ? DateTime.Today : value;
            this.selectedDate = val;
            OnPropertyChanged("SelectedDate");
        }
    }

    Hope this helps.

    Greetings,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • Olena avatar

    Posted on Nov 23, 2011 (permalink)

    So the trix is to declare this property as nullable!!! Date.
    Thanks a lot for your assistance, Ivo.
    Best regards\ Olena

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > DatePicker > Restore a default date when InputBox is blank
Related resources for "Restore a default date when InputBox is blank"

Silverlight DatePicker Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]