11431 : Is there any way to show a background line between the days

Question

 

Is there any way to show a background line between the days? Maybe even hours/minutes depending on scale?< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

Answer

You can do things like that by using the events, this code draws a line each day:

        void gantt1_OnDrawBackground(object sender, GanttUserDrawArgs e)

        {

            e.Canvas.Children.Clear();

            DateTime aDate=gantt10.DateScaler.StartTime;

            aDate=aDate.Date; // only keep date part

            while (aDate<gantt10.DateScaler.StopTime)

            {

                Line line = new Line();

                e.Canvas.Children.Add(line);

                line.X1 = gantt10.DateScaler.TimeToPixel(aDate);

                line.X2 = line.X1;

                line.Y1 = 0;

                line.Y2 = gantt10.ActualHeight;

                line.Stroke = new SolidColorBrush(Colors.Black);

                line.StrokeThickness = 1;

                aDate=aDate.AddDays(1);

            }

        }

Leave a Reply