Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > DatePicker > Update DataContext from DatePicker whitout leaving input field

Not answered Update DataContext from DatePicker whitout leaving input field

Feed from this thread
  • Studach Joerg avatar

    Posted on Apr 22, 2009 (permalink)

    Hi

    When entering a date by hand and NOT tabbing/clicking somewhere outside of the RadDatePicker the SelectedDate is not written down to de DataContext. I know this is a usual behavior in WPF and I have a workaround for the TextBox in form of checking the focused element, getting the bindingexpression and updating it before saving my object. 
    But this doesn't work for the picker as the focused item is a TextBox and not the picker itself and therefore the bindingexpression doesn't exists on this control. How can I achieve the same result?

    My code so far:
       BindingExpression BindingExpr = null
                if (Keyboard.FocusedElement is TextBox) 
                { 
                    BindingExpr = (Keyboard.FocusedElement as TextBox).GetBindingExpression(TextBox.TextProperty); 
     
                    if (BindingExpr != null
                    { 
                        BindingExpr.UpdateSource(); 
                    } 
                } 

    Thanks for response/advice!

    Reply

  • Boyan Boyan admin's avatar

    Posted on Apr 28, 2009 (permalink)

    Hi Studach,

    Unfortunately, this cannot be accomplished at the moment. RadDatePicker does not support this functionality as the properties that can be used are private. There is no way to update the Datepicker and thus DataContext by using the Textbox. 

    Sincerely yours,
    Boyan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • Rachel avatar

    Posted on Aug 11, 2010 (permalink)

    I am having this same problem, and it is a big issue for my application.

    Please tell me there is a way to manually update the DatePicker without losing focus?

    Thanks,
    Rachel

    Reply

  • Kaloyan Kaloyan admin's avatar

    Posted on Aug 17, 2010 (permalink)

    Hi Rachel,

    I am recommending you to use the SelectedValue property instead SelectedDate. This was one of the major changes since the Q2 2010 release as we shipped the new RadDateTimePicker control. As about the problem you are facing - the value entered in the TexBox is being parsed after the control looses its focus. That is why it is not updating the DataContext when on property changed.

    Sincerely yours,
    Kaloyan
    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

    Reply

  • Christoph avatar

    Posted on May 17, 2011 (permalink)

    Hello,

    Have you done any modifications since?

    I would like to now if there is a function to force the parsing of the date so that SelectedValue gets updated, even if the field didn't lose the focus.

    Thank You

    Reply

  • Yana Yana admin's avatar

    Posted on May 20, 2011 (permalink)

    Hi Christoph,

    I suggest you check ParseDateTimeValue event of RadDateTimePicker -  it is fired when you type a character in the control's input box and allows to implement custom parsing of the date.
    More information about the event can be found here.

    Best regards,
    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

    Reply

  • Christoph avatar

    Posted on May 23, 2011 (permalink)

    Hello Yana,

    Thank you for your reply.

    I do not want to implement my own parsing method.
    I would just like to tell the datePicker, please parse the text, like DatePicker.ParseDate()

    Currently this is only done automatically when the control loses its focus or when the user hits the enter key.

    Reply

  • Yana Yana admin's avatar

    Posted on May 25, 2011 (permalink)

    Hi Christoph,

    This is not supported by RadDatePicker - you cannot force parsing the text. In my previous post I suggested to use ParseDateTimeValue event, because in its handler you can get the characters right after they're entered in the input.

    Regards,
    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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > DatePicker > Update DataContext from DatePicker whitout leaving input field
Related resources for "Update DataContext from DatePicker whitout leaving input field"

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