Timebar SelectionEnd off by a day.

2 posts, 0 answers
  1. Nate East
    Nate East avatar
    4 posts
    Member since:
    Jul 2009

    Posted 01 Dec 2015 Link to this post

    My Timebar SelectionStart and SelectionEnd are bound to DateTime properties.  I also have 2 RadDatePickers bound to those date properties.  When I initially load the application, or change the date in the Finish DatePicker, the SelectionEnd date of the TimeBar is off by 1 day.  So if I pick 12/2/2015 in the DatePicker for my finish date, the timebar will display its' finish as 12/1/2015.  When you drag the SelectionEnd bar, or the entire bar, the dates sync back up, but you can cause the problem again by changing the date in the Finish DatePicker.
  2. Dinko
    Dinko avatar
    1114 posts

    Posted 04 Dec 2015 Link to this post

    Hello Nate,

    The described behavior is caused by the nature of the selection feature of RadTimeBar. Basically, the selected interval doesn't include the end date, but it is defined just before it. This behavior reminds of excluding interval end points in mathematics. 

    To achieve your requirement you can use several approaches:
    • Add +1 Tick to the DateTime object that defines the selection end.
    • Change the format string of the selection thumb's Title so that it displays the full date. In your case when you select (for example) 05.10.2012, the DateTime object will have its time set to 12:00:00A.M. and the interval coercion will change it to the 04.10.2012 11:59:59P.M. If you define another format string for the date you will see more accurate info. Here is an example in code:
      void timeBar_Loaded(object sender, RoutedEventArgs e)
          var thumb = ChildrenOfTypeExtensions.FindChildByType<SelectionThumb>(this.timeBar);
          thumb.TitleFormatString = "{0:G} - {1:G}";
    • Hide the Title of the selection thumb. Since, the selection range is displayed in the date pickers above the diagram, the additional info in the thumb is not required and you can remove it.

    I hope that this information is helpful. 
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top