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

Is it possible to host non-sparkline content in the TimeBar thumb?

3 Answers 67 Views
TimeBar
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 23 Jun 2011, 05:46 PM
I would like to put some simple text inside the TimeBar thumb related to the time period being "viewed".  Is this possible or are sparklines the only supported controls?

3 Answers, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 24 Jun 2011, 12:33 PM
Hello Scott,

As the RadTimebar inherits from ContentControl it can host any content you can imagine. We provide examples with the sparkline because it demonstrates a really great synergy between both products but this in no way limits the possible content RadTimeBar can host.

Best wishes,
Vladimir Milev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Will
Top achievements
Rank 1
answered on 23 Aug 2011, 01:27 AM
Adding on to this, if I made my own control for a custom view for the content in the RadTimeBar, how do I use the X values passed from the RadTimeBar?
0
Joel
Top achievements
Rank 1
answered on 23 Aug 2011, 10:55 AM
@Will on Passing X values:
Bind to the PeriodStart and PeriodEnd of the parent time bad. That will be the range of the X values. Dates inbetween are positioned in a linear relationship with the begin and end date. 

@Scott on Positioning Text:

I made a custom control that among other things needs to do something like that. While I can't share the code of the custom control I can share something that may put you in the right area of what you need to do. Let's say that text is the only thing that I needed to display in the timebar. The following XAML would suite that purpose. 

<telerik:RadTimeBar >
  <Grid x:Name="MyContainerEnvelope">
   <Canvas Width="{Binding ElementName=MyContainerEnvelope, Path=ActualWidth}"
                 Height="{Binding ElementName=MyContainerEnveloper, Path=ActualHeight}"
    >
      <TextBlock Text="MyText" />
   </Canvas>
 </Grid>
</telerik:RadTimeBar>

The Grid will grow to occupy all of the content space provided to it. The Canvas control doesn't do that, but it's bound to the Grid's Dimensions so it will have the same behaviour. Right now the text will show up aligned to the left and it needs to be repositioned to be aligned with a specific date. 


void PositionMyText(DateTime targetTime)
{
   double targetPositionPercentage  =  (double)(d - PeriodBegin).Ticks/(double)(PeriodEnd- PeriodBegin).Ticks;
    MyText.SetValue(Canvas.Left, targetPosition*MyContainerEnveloper.ActualWidth);
}

PositionMyText will need to be called anytime the layout of the timebar changes. You can subscribe to the LayoutUpdated event to be notified when you need to call it. 
Tags
TimeBar
Asked by
Scott
Top achievements
Rank 1
Answers by
Vladimir Milev
Telerik team
Will
Top achievements
Rank 1
Joel
Top achievements
Rank 1
Share this question
or