views:

359

answers:

1

I'm using DatePicker and TimePicker from the toolkit. I've got to hook up on the SelectedDateChanged event and I'm also setting the values in code.

My issue is that when I initialise both controls the SelectedDateChanged event doesn't get fired synchronously. That's quite a big issue for me because it means I initialise the control and some time later the event gets fired and changes the current value (because that's what I do in the event handler).

Is there any work around? I tried to listen to some event that get fired once everything is initialized but there's nothing apart from the Loaded event of each control (which is really ugly and gets fired each time the tab on which the controls are gets activated).

EDIT: my problem seemed to go away for a while so I didn't bother looking into it in case it came back. Now it did :(

I use MVVM and initialize the controls within the view in the constructor. Then, when the VM gets the view, it sets the default value as well.

Unfortunately, by the time the VM sets the value the controls haven't got initialized and happen to get themselves intialized some time later (even though I set them in the constructor). They then override the default values.

A: 

There's definitely an issue. However I found a very easy workaround: if I bind the control and don't listen to the SelectedDate event I get the change synchronously and everything works fine.

Took me ages to figure that out but now it's working.

R4cOON