RadiantQ WPF Gantt
How to determine the date at the middle of the current visible view in the chart?
Previous Topic  Next Topic 

How to determine the date at the middle of the current visible view in the chart?


Use this code to determine the date at the middle of the current visible view in the chart:


DateTime viewStart = this.ganttControl.GanttChart.ComputedStartTime;

// Get hte date that is at the left of the current scroll view

double scrollLeft = this.ganttControl.GanttChart.ScrollViewerElement.HorizontalOffset;

DateTime scrollLeftDt = this.ganttControl.GanttChart.ConvertXToTime(scrollLeft);


// Get the date at the right of the current scrollable view

double scrollRight = scrollLeft + this.ganttControl.GanttChart.ActualWidth;

DateTime scrollRightDt = this.ganttControl.GanttChart.ConvertXToTime(scrollRight);


// Date at the middle of the visible view

DateTime middleViewDate = scrollLeftDt + TimeSpan.FromTicks((long)((scrollRightDt - scrollLeftDt).Ticks / 2.0));




� RadiantQ 2009 - 2019. All Rights Reserved.