Update DataContext from DatePicker whitout leaving input field

8 posts, 0 answers
  1. Softec
    Softec avatar
    45 posts
    Member since:
    Sep 2007

    Posted 22 Apr 2009 Link to this post

    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!
  2. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 28 Apr 2009 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Rachel
    Rachel avatar
    37 posts
    Member since:
    Mar 2008

    Posted 11 Aug 2010 Link to this post

    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
  5. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 17 Aug 2010 Link to this post

    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
  6. Christoph
    Christoph avatar
    8 posts
    Member since:
    Mar 2011

    Posted 17 May 2011 Link to this post

    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
  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 20 May 2011 Link to this post

    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
  8. Christoph
    Christoph avatar
    8 posts
    Member since:
    Mar 2011

    Posted 23 May 2011 Link to this post

    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.
  9. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 25 May 2011 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready