This project has moved and is read-only. For the latest updates, please go here.

DateTimePicker TwoWay Binding Loop

Jul 25, 2011 at 7:16 PM

Has anyone had problems with the DateTimePicker when using a TwoWay or OneWayToSource binding on its Value property.  I am seeing an infinite loop on my property Get and Set.

<extToolkit:DateTimePicker Format="Custom" FormatString="HH:mm:ss MM/dd/yyyy" Value="{Binding Path=Value.ClockTime, Mode=TwoWay}" />
Jul 25, 2011 at 11:42 PM

The Value property is TwoWay by default.  Are you getting a stack overflow exception?

Jul 26, 2011 at 3:21 PM

Thanks for replying so fast.  I know the Value property is TwoWay by default--I only explicitly stated it for clarity.  There is no StackOverflow exception, my property Get and Set just keep getting hit continuously back and forth in a loop causing the GUI to flicker and hang-up.

Jul 26, 2011 at 3:44 PM

I have not seen this issue.  If you are not getting a stack overflow then it doesn't seem to be an infinite loop.  The GET will execute anytime the value is being read, so this can appear to be called repeatedly if you have a break point set in the getter and the UI keeps trying to read the value when displayed.  I would check to make sure you don't have any code in the Value.CLockTime property that may be setting values  Can you replicate this issue in a small application?  I will take a look.

Jul 27, 2011 at 2:24 PM

I created a small test app and don't see the same problem.  In the Value.ClockTime property the Get is not setting any value, it only retrieves the value.  The value is only being set in the Set for the Value.ClockTime property.  I have been using an open source DateTime picker but was excited to see the one here in the extended toolkit.  The funny thing is that the Value attribute also has a TwoWay binding in the one I'm currently using and I don't see this problem.  In this version, If I set breakpoints in the Get and Set they will hit one after the other endlessly with no overflow exception.  If I don't set any breakpoints, the property grid GUI just flickers as if it's busy and won't accept any input.  The application I'm using this in is quite large so I can't post it here, and I'm unable to reproduce it in a small test app.

Jul 27, 2011 at 2:33 PM

This tells me that there is something in your larger application that is effecting this value.  Is it possible that the clock time is being set for every tick/second as a real clock would behave?

Jul 27, 2011 at 2:48 PM

No, it starts with a default value of midnight of the current day.  Then, the only place it is being set is in the Setter for the Value.ClockTime property.

Jul 27, 2011 at 2:50 PM

I meant that you need to make sure nothing is setting the Value.ClockTime property else where in the application.