This is a migrated thread and some comments may be shown as answers.

Binding Time Properties to ViewModel Datetimes

1 Answer 98 Views
TimeBar
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 20 Jun 2011, 10:46 AM
Hi

I am using the new TimeBar control to display data loaded from the database via RIA. When I set the date values manually in XAML the TimeBar renders correctly, however when I use the binding to the view model the TimeBar does not render.
The server call does take a few seconds to return but it should still work.

I have tried the assemblies from the previous official release as well as the latest internal build (2011.1.613.1040)

This works
        <telerik:RadTimeBar x:Name="TimeBar" Grid.Row="0" IsSnapToIntervalEnabled="True"
                            PeriodStart="06-01-2006" PeriodEnd="06-01-2011"
                            SelectionStart="05-01-2011" SelectionEnd="05-31-2011"
                            VisiblePeriodStart="01-01-2011" VisiblePeriodEnd="06-01-2011" >
            <telerik:RadTimeBar.Intervals>
                <telerik:YearInterval/>
                <telerik:MonthInterval/>
            </telerik:RadTimeBar.Intervals>
            <telerik:RadAreaSparkline ItemsSource="{Binding Path=ConcernsCountHistory}" Margin="0,8"
                                      XValuePath="MonthStart" YValuePath="ConcernsCount"/>
        </telerik:RadTimeBar>


This does not
         <telerik:RadTimeBar x:Name="TimeBar" Grid.Row="0" IsSnapToIntervalEnabled="True"
                            PeriodEnd="{Binding Path=PeriodEnd,Mode=TwoWay}" PeriodStart="{Binding Path=PeriodStart,Mode=TwoWay}"
                            SelectionEnd="{Binding Path=SelectionEnd,Mode=TwoWay}" SelectionStart="{Binding Path=SelectionStart,Mode=TwoWay}"
                            VisiblePeriodEnd="{Binding Path=VisibleSelectionEnd,Mode=TwoWay}" VisiblePeriodStart="{Binding Path=VisibleSelectionStart,Mode=TwoWay}">            
            <telerik:RadTimeBar.Intervals>
                <telerik:YearInterval/>
                <telerik:MonthInterval/>
            </telerik:RadTimeBar.Intervals>
            <telerik:RadAreaSparkline ItemsSource="{Binding Path=ConcernsCountHistory}" Margin="0,8"
                                      XValuePath="MonthStart" YValuePath="ConcernsCount"/>
        </telerik:RadTimeBar>



ViewModel
    Public Property ConcernsCountHistory As ReadOnlyObservableCollection(Of ConcernCountsHistory)
        Get
            Return _concernsCountHistory
        End Get
        Set(ByVal value As ReadOnlyObservableCollection(Of ConcernCountsHistory))
            _concernsCountHistory = value
            If value.Count > 0 Then
                InitialiseDateRanges()
            End If
            RaisePropertyChanged("ConcernsCountHistory")
        End Set
    End Property
 
    Public Property PeriodStart As DateTime
        Get
            Return _periodStart
        End Get
        Set(ByVal value As DateTime)
            _periodStart = value
            RaisePropertyChanged("PeriodStart")
        End Set
    End Property
 
    Public Property PeroiodEnd As DateTime
        Get
            Return _periodEnd
        End Get
        Set(ByVal value As DateTime)
            _periodEnd = value
            RaisePropertyChanged("PeroiodEnd")
        End Set
    End Property
 
    Public Property VisibleSelectionStart As DateTime
        Get
            Return _visibleStart
        End Get
        Set(ByVal value As DateTime)
            _visibleStart = value
            RaisePropertyChanged("VisibleSelectionStart")
        End Set
    End Property
 
    Public Property VisibleSelectionEnd As DateTime
        Get
            Return _visibleEnd
        End Get
        Set(ByVal value As DateTime)
            _visibleEnd = value
            RaisePropertyChanged("VisibleSelectionEnd")
        End Set
    End Property
 
    Public Property SelectionStart As DateTime
        Get
            Return _selectionStart
        End Get
        Set(ByVal value As DateTime)
            _selectionStart = value
            RaisePropertyChanged("SelectionStart")
        End Set
    End Property
 
    Public Property SelectionEnd As DateTime
        Get
            Return _selectionEnd
        End Get
        Set(ByVal value As DateTime)
            _selectionEnd = value
            RaisePropertyChanged("SelectionEnd")
        End Set
    End Property

    Private Sub InitialiseDateRanges()
        PeroiodEnd = _concernsCountHistory.Last.MonthStart
        PeriodStart = _concernsCountHistory.First.MonthStart
        VisibleSelectionEnd = New Date(Date.Now.Year, Date.Now.Month, 1)
        VisibleSelectionStart = New Date(DateAdd(DateInterval.Month, -12, Date.Now).Year, DateAdd(DateInterval.Month, -1, Date.Now).Month, 1)
        SelectionEnd = New Date(Date.Now.Year, Date.Now.Month, 1)
        SelectionStart = New Date(DateAdd(DateInterval.Month, -1, Date.Now).Year, DateAdd(DateInterval.Month, -1, Date.Now).Month, 1)
    End Sub

Any ideas?

Phil

1 Answer, 1 is accepted

Sort by
0
Phil
Top achievements
Rank 1
answered on 20 Jun 2011, 11:14 AM
Nevermind, the problem was a typo on the period end in the viewmodel
Tags
TimeBar
Asked by
Phil
Top achievements
Rank 1
Answers by
Phil
Top achievements
Rank 1
Share this question
or