How to Have Infinite Horizontal Scrolling
Environment
Product | RadGanttView for WPF |
Description
How to achieve infinite horizontal scrolling in the TimeRuler part.
Solution
Handle the Loaded event of the RadGanttView and obtain a reference to the ScrollBar in the EventsPanel inside the RadGanttView. Then you can handle its Scroll event and increase the VisibleRange of the RadGanttView, if the Value of the ScrollBar is approaching the ExtentWidth of the EventsPanel.
private LogicalCanvasPanel eventsPanel;
private void RadGanttView_Loaded(object sender, RoutedEventArgs e)
{
var ganttView = sender as RadGanttView;
this.eventsPanel = ganttView.ChildrenOfType<LogicalCanvasPanel>().First(p => p.Name == "EventsPanel");
var eventsPanelScrollbar = ganttView.ChildrenOfType<ScrollBar>().Skip(1).FirstOrDefault();
eventsPanelScrollbar.Scroll += Scrollbar_Scroll;
}
private void Scrollbar_Scroll(object sender, ScrollEventArgs e)
{
var scrollBar = sender as ScrollBar;
if (scrollBar.Value + 100 > this.eventsPanel.ExtentWidth)
{
var currentVisibleRange = this.ganttView.VisibleRange;
this.ganttView.VisibleRange = new DateRange(currentVisibleRange.Start, currentVisibleRange.End.AddDays(50));
}
}