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

Possible bug when binding to RadTimeline's PeriodStart, PeriodEnd

2 Answers 122 Views
TimeLine
This is a migrated thread and some comments may be shown as answers.
Johannes
Top achievements
Rank 1
Johannes asked on 26 Jun 2012, 05:39 PM
I want to bind the properties PeriodStart, PeriodEnd, VisiblePeriodStart, and VisiblePeriodEnd to my ViewModel, but it doesn't work like expected. Could this be a bug in the RadTimeline control?

My ViewModel class is called ParentViewModel:

public class ParentViewModel : ViewModelBase
{
    public String Name { get; set; }
    //public DateTime Start { get { return ChildItems.Min(x => x.Start); } }
    //public DateTime End { get { return ChildItems.Max(x => x.End); } }
    public DateTime Start { get { return DateTime.Now; } }
    public DateTime End { get { return DateTime.Now.AddDays(7.0);  } }
    public TimeSpan Duration { get { return End - Start; } }
    public ObservableCollection<TestViewModel> ChildItems { get; private set; }
 
    public ParentViewModel()
    {
        ChildItems = new ObservableCollection<TestViewModel>();
    }
 
    public void AddChilds(IEnumerable<TestViewModel> childs)
    {
        foreach (var x in childs)
        {
            ChildItems.Add(x);
        }
    }
 
    public void FirePropertysChanged()
    {
        OnPropertyChanged("Start");
        OnPropertyChanged("End");
    }
}

I set an instance of this class as the DataContext of a RadTimeline, and bind the PeriodStart and PeriodEnd properties like this:

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
 
    <StackPanel Orientation="Horizontal" Margin="2">
        <TextBlock FontWeight="Bold" Text="PeriodStart: " />
        <TextBlock Text="{Binding Start}"/>
    </StackPanel>
 
    <StackPanel Orientation="Horizontal" Grid.Row="1" Margin="2">
        <TextBlock FontWeight="Bold" Text="PeriodEnd: " />
        <TextBlock Text="{Binding End}"/>
    </StackPanel>
 
    <telerik:RadTimeline x:Name="radTimeline1" Grid.Row="2"
                         PeriodStart="{Binding Start}"
                         PeriodEnd="{Binding End}"
                         StartPath="Start"
                         DurationPath="Duration"
                         ItemsSource="{Binding ChildItems}">
        <telerik:RadTimeline.Intervals>
            <telerik:MonthInterval />
            <telerik:WeekInterval />
            <telerik:DayInterval />
            <telerik:HourInterval />
            <telerik:MinuteInterval />
        </telerik:RadTimeline.Intervals>
    </telerik:RadTimeline>
 
</Grid>

The Start and End properties are correctly bound to the TextBlocks and the Dates are displayed. 
However, the RadTimeline's content is blank. 
I tried to raise the OnPropertyChanged events (in the method FirePropertysChanged in my ViewModel), but that doesn't help.
When the date values are hardcoded in XAML, the RadTimeline works. But it doesn't work if bound to a ViewModel.
Could this be a bug?

2 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetie
Telerik team
answered on 02 Jul 2012, 08:18 AM
Hi Johannes,

Please use two-way binding, when binding the period properties of RadTimeline. You can refer to any of our online demos for a sample code snippet - in all demos, these properties are bound to properties of the view model.

For additional information, please refer to our online documentation.

Regards,
Tsvetie
the Telerik team

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

0
Ola
Top achievements
Rank 1
answered on 29 Oct 2014, 10:24 AM
Great info. I also had a similar issue with period-bindings, but with twoway binding it works as expected.
Tags
TimeLine
Asked by
Johannes
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Ola
Top achievements
Rank 1
Share this question
or