CurrentDateTimeText is null when changing DataContext

4 posts, 0 answers
  1. ClausDC
    ClausDC avatar
    58 posts
    Member since:
    Feb 2010

    Posted 07 Aug 2013 Link to this post

    I have a binding on "SelectedValue" and "CurrentDateTimeText".

    Now when I Change the ViewModel (DataContext) "CurrentDateTimeText" is set to null despite "SelectedValue" having a value. Only when the user "physical" changes something in the Input text box of the control the "CurrentDateTimeText"-Property gets updated.

    This causes a number of Problems in my Setup which I have to work around.

    Why is this property not properly updated?
  2. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 07 Aug 2013 Link to this post

    Hi Claus,

    Could you please give us more details on the described scenario and how exactly do you change the DataContext? If you could provide a sample project which demonstrates the situation would be really helpful for us to assist you further.

    I'm looking forward to your response.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. ClausDC
    ClausDC avatar
    58 posts
    Member since:
    Feb 2010

    Posted 08 Aug 2013 Link to this post


    I wrote a little sample application to demonstrate this.

    It's quite simple really. Just change the ViewModel via the button and the binded value of CurrentDateTimeText is "null".

    https://dl.dropboxusercontent.com/u/75709329/TelerikDateTimePickerTest.zip
  5. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 13 Aug 2013 Link to this post

    Hi Claus,

    We tested the provided project and appears that the explained behavior is caused from the SelectedValue property. When you change the ViewModel and assign value to the BeginningDate property it is not firing the PropertyChanged event because the SelectedValue of the DateTimePicker is currently the same as the BeggingDate and this is the reason the CurrentDateTimeText value is not updated.

    If could you give us some more details on your scenario (What is the reason to change the ViewModel at run-time? Do you need the new ViewModel to have the same SelectedValue?), we will be able to investigate further and provide you with a solution.

    I'm looking forward to your response.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top