ScheduleView and TimeBar example set visible period bug

3 posts, 1 answers
  1. Sergey
    Sergey avatar
    26 posts
    Member since:
    Jun 2012

    Posted 25 Jun 2012 Link to this post

    In my application I am using code of TimeBar demo http://demos.telerik.com/silverlight/#ScheduleView/TimeBar, but can't get over a bug in Telerik.Windows.Examples.ScheduleView.TimeBar.Example class. Only visible period start is being set when TimeBar slider is moved:
    1. user moves TimeBar slider,
    2. TimeBar_VisiblePeriodChanged() fires 1st time,
    3. TimeBar rounded visible period start is set at line
      this.TimeBar.VisiblePeriodStart = roundedVisiblePeriodStart;

      and this is reflected in browser,
    4. TimeBar_VisiblePeriodChanged() fires 2nd time,
    5. compiler executes rounded visible period end assignment line
      this.TimeBar.VisiblePeriodEnd = roundedVisiblePeriodEnd;

      but visually nothing happens in browser and TimeBar_VisiblePeriodChanged() while expected doesn't fire for the 3rd time.

    This results firstly in loss of visual synchronization between TimeBar and MinimapSchedule, and secondly in slidebar growing after each dragging operation.

    The effect is especially pronounced when you adjust visible period to show days instead of weeks:
    <telerik:RadTimeBar x:Name="TimeBar" Margin="2" Grid.ColumnSpan="2"
            telerik:StyleManager.Theme="Metro" Background="Transparent" PeriodStart="6/1/2011 12:00:00 AM"
            PeriodEnd="7/1/2011 11:59:59 PM" VisiblePeriodStart="6/7/2011 12:00:00 AM"
            VisiblePeriodEnd="6/22/2011 11:59:59 PM" SelectionStart="6/14/2011 12:00:00 AM"
            SelectionEnd="6/14/2011 11:59:59 PM" MinSelectionRange="1.00:00:00" MaxSelectionRange="7.00:00:00"
            MinZoomRange="1.00:00:00" IsSnapToIntervalEnabled="True"
            VisiblePeriodChanged="TimeBar_VisiblePeriodChanged">

     

  2. Answer
    Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 28 Jun 2012 Link to this post

    Hi Sergey,

    You can use the following approach to correct the problem that you describe:
    private bool updateInProgress = false;
     
    private void TimeBar_VisiblePeriodChanged(object sender, RadRoutedEventArgs e)
    {
        if (this.updateInProgress)
            return;
     
        if (this.TimeBar != null)
        {
            DateTime roundedVisiblePeriodStart = this.TimeBar.VisiblePeriodStart.Date;
            DateTime roundedVisiblePeriodEnd = this.TimeBar.VisiblePeriodEnd.Date;
     
            this.updateInProgress = true;
     
            if (roundedVisiblePeriodStart != this.TimeBar.VisiblePeriodStart)
            {
                this.TimeBar.VisiblePeriodStart = roundedVisiblePeriodStart;
            }
            if (roundedVisiblePeriodEnd != this.TimeBar.VisiblePeriodEnd)
            {
                this.TimeBar.VisiblePeriodEnd = roundedVisiblePeriodEnd;
            }
     
            this.updateInProgress = false;
     
            this.UpdateMinimap();
        }
    }

    Kind regards,
    Tsvetie
    the Telerik team

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

  3. DevCraft banner
  4. Sergey
    Sergey avatar
    26 posts
    Member since:
    Jun 2012

    Posted 29 Jun 2012 Link to this post

    Thanks!
Back to Top