I am working with the TimeBar control in a MVVM environment (CaliburnMicro) and am trying to bind the PeriodEnd and PeriodStart properties of the TimeBar. I was getting some exceptions and thought I would pass along what I did to get it working. The key was to make sure to set a FallBackValue in the binding like so:
I was getting two seperate exceptions depending on if I was trying to bind the PeriodEnd or PeriodStart.
PeriodEnd Exception:
PeriodStart Exception:
The added or subtracted value results in an un-representable DateTime.
Parameter name: value
at System.DateTime.AddTicks(Int64 value)
at System.DateTime.Add(Double value, Int32 scale)
at System.DateTime.AddDays(Double value)
at Telerik.Windows.Controls.TimeBar.WeekInterval.ExtractIntervalStart(DateTime date)
at Telerik.Windows.Controls.TimeBar.PeriodSpanGenerator.GenerateModels(DateTime periodStart, DateTime periodEnd, Func`2 extractIntervalStartAction, Func`2 incrementAction)
at Telerik.Windows.Controls.TimeBar.IntervalDescriptor.UpdatePeriods(DateTime periodStart, DateTime periodEnd)
at Telerik.Windows.Controls.RadTimeBar.SynchronizeIntervalDescriptors()
at Telerik.Windows.Controls.RadTimeBar.EndInit()
at MS.Internal.FrameworkCallbacks.SupportInitializeEndInit(IntPtr nativeTarget)
While trying to figure out what was going on, I tried binding the TimeBars height property, which worked as I expected. However, if the view model property does not exist (like if you mis-spell it in the binding), then I got the same exception as with PeriodEnd (SerializationException). However this behavior does not occur on the RadChart control, or the out of the box silverlight controls. So it would seem that the TimeBar could use some better error handling, but I realize it's still in beta.
PeriodEnd="{Binding PeriodEnd, FallbackValue='12/31/2011'}"
I was getting two seperate exceptions depending on if I was trying to bind the PeriodEnd or PeriodStart.
PeriodEnd Exception:
System.Runtime.Serialization.SerializationException
Type 'System.Windows.LayoutCycleException' in assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' is not marked as serializable.
PeriodStart Exception:
The added or subtracted value results in an un-representable DateTime.
Parameter name: value
at System.DateTime.AddTicks(Int64 value)
at System.DateTime.Add(Double value, Int32 scale)
at System.DateTime.AddDays(Double value)
at Telerik.Windows.Controls.TimeBar.WeekInterval.ExtractIntervalStart(DateTime date)
at Telerik.Windows.Controls.TimeBar.PeriodSpanGenerator.GenerateModels(DateTime periodStart, DateTime periodEnd, Func`2 extractIntervalStartAction, Func`2 incrementAction)
at Telerik.Windows.Controls.TimeBar.IntervalDescriptor.UpdatePeriods(DateTime periodStart, DateTime periodEnd)
at Telerik.Windows.Controls.RadTimeBar.SynchronizeIntervalDescriptors()
at Telerik.Windows.Controls.RadTimeBar.EndInit()
at MS.Internal.FrameworkCallbacks.SupportInitializeEndInit(IntPtr nativeTarget)
While trying to figure out what was going on, I tried binding the TimeBars height property, which worked as I expected. However, if the view model property does not exist (like if you mis-spell it in the binding), then I got the same exception as with PeriodEnd (SerializationException). However this behavior does not occur on the RadChart control, or the out of the box silverlight controls. So it would seem that the TimeBar could use some better error handling, but I realize it's still in beta.