This is a migrated thread and some comments may be shown as answers.

CurrentDateTimeText is null when changing DataContext

3 Answers 62 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
ClausDC
Top achievements
Rank 1
Iron
ClausDC asked on 07 Aug 2013, 08:28 AM
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?

3 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 07 Aug 2013, 03:45 PM
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 >>
0
ClausDC
Top achievements
Rank 1
Iron
answered on 08 Aug 2013, 07:44 AM

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
0
Kalin
Telerik team
answered on 13 Aug 2013, 08:45 AM
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 >>
Tags
DateTimePicker
Asked by
ClausDC
Top achievements
Rank 1
Iron
Answers by
Kalin
Telerik team
ClausDC
Top achievements
Rank 1
Iron
Share this question
or