I'm using a RadTimeBar that only displays 24 hours of data at a time. Below is a sample application to reproduce the issue I'm having:
And the XAML:
On the initial load, all works fine. In the scroller at the bottom, you can re-size the selection as normal (dragging on each size of the scroll bar), and it won't let you zoom too far in.
But I have to be able to change the period on the fly. I have a datePicker that allows the user to change the date for the data in the timebar. So I need to change the 'PeriodStart' and 'PeriodEnd' from code-behind. In the example above, I just hard-coded it in a button click. After I do this, it seems as if you can zoom in infinitely and the application eventually crashes with an overflow exception "Arithmetic operation resulted in an overflow". Sometimes, it throws the exception immediately after zooming in too far. Sometimes you have to drag/zoom in and out a few times.
Is there another way to change 'PeriodStart' and 'PeriodEnd' after it is initially loaded? Or is there a way to 're-initialize' the control after changing the period properties, so that you can't zoom in infinitely?
namespace TimelineTest{ public partial class MainWindow : Window { private List<Item> items = new List<Item>(); public MainWindow() { InitializeComponent(); items.Add(new Item() { Date = new DateTime(2014, 5, 5), Duration = TimeSpan.FromHours(5) }); items.Add(new Item() { Date = new DateTime(2014, 5, 5, 14, 18, 22), Duration = TimeSpan.FromHours(5) }); timeline.ItemsSource = items; } public class Item { public TimeSpan Duration { get; set; } public DateTime Date { get; set; } } private void Button_Click(object sender, RoutedEventArgs e) { DateTime now = DateTime.Now; timebar.PeriodStart = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0); timebar.PeriodEnd = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59); } }}And the XAML:
<Window x:Class="TimelineTest.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="350" Width="525"> <Grid> <telerik:RadTimeBar Name="timebar" Height="64" Margin="10,0,10,193" PeriodStart="5/5/2014 00:00:00" PeriodEnd="05/5/2014 23:59:59" VerticalAlignment="Bottom" MaxSelectionRange="0:0:10" MinSelectionRange="0:0:10" SelectionTitleFormatString="{}{0:MM-dd-yy HH:mm:ss}"> <telerik:RadTimeBar.Intervals> <telerik:HourInterval IntervalSpans="1,4"/> <telerik:MinuteInterval IntervalSpans="1,5,15,30"/> </telerik:RadTimeBar.Intervals> <telerik:RadTimeBar.Content> <telerik:RadTimeline Name="timeline" Margin="0, -65, 0, 0" PeriodStart="{Binding PeriodStart, ElementName=timebar}" PeriodEnd="{Binding PeriodEnd, ElementName=timebar}" telerik:StyleManager.Theme="Windows8Touch" StartPath="Date" DurationPath="Duration" ScrollMode="None"> <telerik:RadTimeline.Intervals> <telerik:DayInterval IntervalSpans="1"/> </telerik:RadTimeline.Intervals> </telerik:RadTimeline> </telerik:RadTimeBar.Content> </telerik:RadTimeBar> <Button Content="Button" HorizontalAlignment="Left" Margin="125,230,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/> </Grid></Window>On the initial load, all works fine. In the scroller at the bottom, you can re-size the selection as normal (dragging on each size of the scroll bar), and it won't let you zoom too far in.
But I have to be able to change the period on the fly. I have a datePicker that allows the user to change the date for the data in the timebar. So I need to change the 'PeriodStart' and 'PeriodEnd' from code-behind. In the example above, I just hard-coded it in a button click. After I do this, it seems as if you can zoom in infinitely and the application eventually crashes with an overflow exception "Arithmetic operation resulted in an overflow". Sometimes, it throws the exception immediately after zooming in too far. Sometimes you have to drag/zoom in and out a few times.
Is there another way to change 'PeriodStart' and 'PeriodEnd' after it is initially loaded? Or is there a way to 're-initialize' the control after changing the period properties, so that you can't zoom in infinitely?
