failed to convert value Telerik.Windows.Controls.SelectionRange

3 posts, 0 answers
  1. Rav
    Rav avatar
    36 posts
    Member since:
    Nov 2011

    Posted 03 Aug 2011 Link to this post

    Hi Telerik,

    I'm getting the following error when using RadTimeBar

    System.Windows.Data Error: 'MS.Internal.Data.DynamicValueConverter' converter failed to convert value 'Telerik.Windows.Controls.SelectionRange`1[System.Double]' (type 'Telerik.Windows.Controls.SelectionRange`1[System.Double]'); BindingExpression: Path='ActualVisiblePeriodRange' DataItem='Telerik.Windows.Controls.RadTimeBar' (HashCode=29235797); target element is 'Telerik.Windows.Controls.RadSlider' (Name='PART_Slider'); target property is 'Selection' (type 'Telerik.Windows.Controls.SelectionRange`1[System.Double]').. System.InvalidOperationException: Can't convert type Telerik.Windows.Controls.SelectionRange`1[System.Double] to type Telerik.Windows.Controls.SelectionRange`1[System.Double].
       at MS.Internal.Data.DefaultValueConverter.Create(Type sourceType, Type targetType, Boolean targetToSource)
       at MS.Internal.Data.DynamicValueConverter.EnsureConverter(Type sourceType, Type targetType)
       at MS.Internal.Data.DynamicValueConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
       at System.Windows.Data.BindingExpression.ConvertToTarget(Object value).

    This is the XAML

    <telerik:RadTimeBar Grid.Row="1" IsSnapToIntervalEnabled="True"
                    PeriodStart="{Binding PeriodStart, Mode=TwoWay}"
                    PeriodEnd="{Binding PeriodEnd, Mode=TwoWay}"
                    VisiblePeriodStart="{Binding VisiblePeriodStart, Mode=TwoWay}"
                    VisiblePeriodEnd="{Binding VisiblePeriodEnd, Mode=TwoWay}"
                    SelectionStart="{Binding SelectionStart, Mode=TwoWay}"
                    SelectionEnd="{Binding SelectionEnd, Mode=TwoWay}">
                    <telerik:RadTimeBar.Intervals>
                        <telerik:YearInterval />
                        <telerik:MonthInterval />
                        <telerik:WeekInterval />
                        <telerik:DayInterval />        
                    </telerik:RadTimeBar.Intervals>
                    <telerik:RadColumnSparkline ItemsSource="{Binding Statistics}" XValuePath="CompletedDate" YValuePath="NumberCompleted" />
                </telerik:RadTimeBar>

    And this is the ViewModel

    public Dashboard04ViewModel()
            {
                var rand = new Random();
                var start = DateUtilities.GetStartOfCurrentYear();
     
                Statistics = new List<ProgramCompletionStatistic>();
                while (start < DateUtilities.GetEndOfCurrentYear())
                {
                    var randNum = (int) (rand.NextDouble()*15);
                     
                    Statistics.Add(
                        new ProgramCompletionStatistic
                            {
                                CompletedDate = start,
                                NumberCompleted = randNum
                            });
                     
                    start = start.AddDays(1);
                }
                //NotifyPropertyChanged("Statistics");
     
                PeriodStart = DateUtilities.GetStartOfCurrentYear();
                PeriodEnd = DateUtilities.GetEndOfCurrentMonth();
                VisiblePeriodStart = DateUtilities.GetStartOfCurrentWeek();
                VisiblePeriodEnd = DateUtilities.GetEndOfCurrentWeek();
                SelectionStart = DateUtilities.GetStartOfCurrentWeek();
                SelectionEnd = DateUtilities.GetEndOfCurrentWeek();
     
                if (!Designer.IsInDesignMode)
                {
                }
            }
     
            #endregion
     
            #region Public Methods/Properties               
     
            public List<ProgramCompletionStatistic> Statistics { get; set; }
     
            private DateTime _periodStart;
            public DateTime PeriodStart
            {
                get { return _periodStart; }
                set
                {
                    _periodStart = value;
                    NotifyPropertyChanged("PeriodStart");
                }
            }
     
            private DateTime _periodEnd;
            public DateTime PeriodEnd
            {
                get { return _periodEnd; }
                set
                {
                    _periodEnd = value;
                    NotifyPropertyChanged("PeriodEnd");
                }
            }
     
            private DateTime _visiblePeriodStart;
            public DateTime VisiblePeriodStart
            {
                get { return _visiblePeriodStart; }
                set
                {
                    _visiblePeriodStart = value;
                    NotifyPropertyChanged("VisiblePeriodStart");
                }
            }
     
            private DateTime _visiblePeriodEnd;
            public DateTime VisiblePeriodEnd
            {
                get { return _visiblePeriodEnd; }
                set
                {
                    _visiblePeriodEnd = value;
                    NotifyPropertyChanged("VisiblePeriodEnd");
                }
            }
     
            private DateTime _selectionStart;
            public DateTime SelectionStart
            {
                get { return _selectionStart; }
                set
                {
                    _selectionStart = value;
                    NotifyPropertyChanged("SelectionStart");
                }
            }
     
            private DateTime _selectionEnd;
            public DateTime SelectionEnd
            {
                get { return _selectionEnd; }
                set
                {
                    _selectionEnd = value;
                    NotifyPropertyChanged("SelectionEnd");
                }
            }

    Could you please help? I assume it is to do with binding the dates?

    Rav
  2. Rav
    Rav avatar
    36 posts
    Member since:
    Nov 2011

    Posted 03 Aug 2011 Link to this post

    could it be something to do with my DateTime formatting? I am in Australia.
  3. DevCraft banner
  4. Missing user
    Missing user avatar

    Posted 05 Aug 2011 Link to this post

    Hello Rav Panchalingam,

    Thank you for the detailed explanation and the code snippets. However, it is hard for me to determine the cause of the issue from the information provided. Could you please open a new formal thread (Support thread) and send us a sample runnable project (where this issue occurs) with dummy data? We will debug it locally, and advise you further.

    Regards,
    Polina
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Back to Top