Possible bug when binding to RadTimeline's PeriodStart, PeriodEnd

3 posts, 1 answers
  1. Johannes
    Johannes avatar
    13 posts
    Member since:
    Mar 2011

    Posted 26 Jun 2012 Link to this post

    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. Answer
    Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 02 Jul 2012 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Ola
    Ola avatar
    15 posts
    Member since:
    Jun 2014

    Posted 29 Oct 2014 in reply to Tsvetie Link to this post

    Great info. I also had a similar issue with period-bindings, but with twoway binding it works as expected.
Back to Top