{System.ArgumentException: '0' is not a valid value for property 'System.Windows.CustomDependencyProperty'.
at Telerik.Windows.PropertyMetadata.PropertyChangeHook.OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
at System.Windows.Data.BindingExpression.SendDataToTarget()
at System.Windows.Data.BindingExpression.SourcePropertyChanged(PropertyPathListener sender, PropertyPathChangedEventArgs args)
at System.Windows.PropertyPathListener.ReconnectPath()
at System.Windows.Data.Debugging.BindingBreakPoint.<>c__DisplayClass4.<BreakOnSharedType>b__3()}
The error is occuring when I call the OnPropertyChanged for either the SelectionStart or SelectionEnd. And does not happen every time. Very random.
OnPropertyChanged(() => SelectionStart);
or
OnPropertyChanged(() => SelectionEnd);
This is what I am trying to do. <-- notice I am even trying to be sure that the startDate is never greater than the endDate of the RadTimeBar.
private void SetSelectionDates(DateTime value)
{
TimeSpan ts = _selectionEnd - _selectionStart;
int days = ts.Days;
DateTime startDt = value;
DateTime endDt = value.AddDays(days).AddHours(_selectionEnd.Hour).AddMinutes(_selectionEnd.Minute).AddSeconds(_selectionEnd.Second);
bool doSelectionStartFirst = (_selectionEnd >= value);
if (doSelectionStartFirst)
{
SelectionStart = startDt;
SelectionEnd = endDt;
}
else
{
SelectionEnd = endDt;
SelectionStart = startDt;
}
}
Here is the Xaml.
<telerik:RadTimeBar x:Name="TimeBar" Margin="2" Grid.ColumnSpan="2"
telerik:StyleManager.Theme="Office_Blue"
Background="Transparent"
PeriodStart="{Binding PeriodStart, Mode=TwoWay}"
PeriodEnd="{Binding PeriodEnd, Mode=TwoWay}"
VisiblePeriodStart="{Binding VisiblePeriodStart, Mode=TwoWay}"
VisiblePeriodEnd="{Binding VisiblePeriodEnd, Mode=TwoWay}"
SelectionEnd="{Binding SelectionEnd, Mode=TwoWay}"
SelectionStart="{Binding SelectionStart, Mode=TwoWay}"
MinSelectionRange="{Binding MinSelectionRange, Mode=TwoWay}"
MaxSelectionRange="{Binding MaxSelectionRange, Mode=TwoWay}"
MinZoomRange="{Binding MinZoomRange, Mode=TwoWay}"
IsSnapToIntervalEnabled="False"
VisiblePeriodChanged="TimeBarVisiblePeriodChanged"
>
Here are the view model properties.
private DateTime _selectionStart;
public DateTime SelectionStart
{
get { return _selectionStart; }
set
{
_selectionStart = value;
OnPropertyChanged(() => SelectionStart);
}
}
private DateTime _selectionEnd;
public DateTime SelectionEnd
{
get { return _selectionEnd; }
set
{
_selectionEnd = value;
OnPropertyChanged(() => SelectionEnd);
}
}