Real-Time TimeBar and Auto-Expand

4 posts, 0 answers
  1. Tyler
    Tyler avatar
    7 posts
    Member since:
    Aug 2013

    Posted 09 Jan 2015 Link to this post

    Hello, two questions in one thread:

    1. Is there any way to get real-time changes in VisiblePeriodStart and VisiblePeriodEnd?

    2. I have a TimeBar whose PeriodEnd changes several times a second, and double-clicking to maximize the TimeBar's visible period doesn't cause the TimeBar to keep up with new PeriodEnd changes. Is there any way to set the TimeBar to auto-expand its visible period in code-behind?

    Thank you!
  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 14 Jan 2015 Link to this post

    Hi Tyler,

    Let me get straight to your questions:
    1. Is there any way to get real-time changes in VisiblePeriodStart and VisiblePeriodEnd?
      Yes, there are couple approaches to get the runtime changes in the visible period range. The first one is to subscribe for the VisiblePeriodChanged event of RadTimeBar and get the . The other one is to bind the VisiblePeriodEnd/Start properties to properties from your view model that listens for changes through the INotifyPropertyChanged interface. This way each time the visible period is change the setters of the properties in your view model will be called.
    2.  I have a TimeBar whose PeriodEnd changes several times a second, and double-clicking to maximize the TimeBar's visible period doesn't cause the TimeBar to keep up with new PeriodEnd changes. Is there any way to set the TimeBar to auto-expand its visible period in code-behind?
      You can expand the timebar's visible period in code-behind by setting its VisiblePeriodStart and VisiblePeriodEnd properties. For example:
      var newPeriodEnd = this.model.PeriodEnd.AddHours(1);
      this.model.PeriodEnd = newPeriodEnd;
       
      if (visible is range maximized)
      {
          this.model.VisiblePeriodEnd = newPeriodEnd;
      }
      However, when you set the PeriodEnd to a new value and then set the VisiblePeriodEnd to the same value, since the scroll UI element (which is RadSlider) works with Ticks there might be a double rounding and this is why the flicker appears. To resolve this you can set the UseLayoutRounding property of the RadTimeBar control to True.

    Regards,
    Martin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Tyler
    Tyler avatar
    7 posts
    Member since:
    Aug 2013

    Posted 14 Jan 2015 in reply to Martin Link to this post

    Hey Martin, thanks for the response.

    1. I'm currently subscribed to VisiblePeriodChanged and I only get event updates when the user has released the mouse after panning/zooming (not real-time). My model also implements INotifyPropertyChanged and it shows the same update pattern. For context I'm using the 2013 Q2 release.

    2. I've implemented your fix and it works fine, I was just hoping there was a more elegant built-in "AutoExpandMode = Expand" solution. Thank you though, this answers the question.
  5. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 16 Jan 2015 Link to this post

    Hello Tyler,

    The VisiblePeriodRange is updated when the dragging of the slider is completed and the mouse is up. However, RadTimeBar exposes a ActualVisibleRange property that holds the actual range of the slider and it is updated while dragging (panning, zooming) the slider. You can use it to achieve your requirement.

    If you want to execute a logic when the property is changed you can create a property in your view model that holds the actual range and bind it in one way to source mode with the ActualVisiblePeriodRange of the time bar. Then call your logic in the custom property's setter.

    If this does not help, can you describe what you want to achieve? This way we will better understand your scenario and we will be able to assist you further.

    Regards,
    Martin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top