RadiantQ WPF Gantt
Getting Started in VS2010 and VS2012
Previous Topic  Next Topic 

Toolbox Entries


Create a tab in VS.NET Toolbox called "RadiantQ WPF Controls" for example.


Add GanttControl to your Toolbox


In a VS 2010/2012 WPF Project, select the "ToolBox/Choose Items..." context menu. This will bring up the "Choose Toolbox Items" dialog box.


In the dialog box, select the "WPF Components" tab, click on the "Browse..." button and select the RadiantQ.GanttControls.WPF.dll from the "C:\Program Files\RadiantQ\WPF Gantt 1.7\bin" folder.


Select all the controls in the RadiantQ.* namespace.

(Note: If you have trouble setting up the Toolbox, please follow the steps outlined here to manually add references to the GanttControl in your project)




Adding GanttControl to XAML


Now you can drag and drop a GanttControl into your WPF window. Give the newly added control a name. The resultant XAML should look like this (remove the unnecessary margin and alignment settings):


  <Grid x:Name="LayoutRoot">

        <my:GanttControl x:Name="ganttControl1"></my:GanttControl>

  </Grid>


Initializing GanttControl with some tasks


Then in your code behind create a list of task items as follows and bind it to the control's ItemsSource.

// Reference this namespace on top of the cs file

using RadiantQ.Windows.Controls.Gantt;


        public MainPage()

        {

            InitializeComponent();


               DateTime dtStart = TimeComputingUtils.ToUtcKind(DateTime.Today);

            // TaskInfo is a built-in type that represents a task/activity in the GanttControl.

            List<TaskInfo> taskItems = new List<TaskInfo>

            {

                new TaskInfo { Name = "Task 1", ID = 1, StartTime = dtStart, Effort=TimeSpan.Parse("8:00:00"), Description = "Description of Task 1" },

                new TaskInfo { Name = "Task 2", ID = 2, PredecessorIndices="1", StartTime = dtStart, Effort=TimeSpan.Parse("16:00:00"), Description = "Description of Task 2" },

                new TaskInfo { Name = "Task 3",  ID = 3,  StartTime = dtStart, Effort = TimeSpan.Parse("12:30:00"), ProgressPercent=50, Description = "Description of Task 3" },

                new TaskInfo { Name = "Child Task 1", ID = 4, IndentLevel = 1, StartTime = dtStart, Effort = TimeSpan.Parse("08:00:00"),  ProgressPercent=40, Description = "Description of Task 3/Child Task 1" },

                new TaskInfo { Name = "Child Task 2", ID = 5, IndentLevel = 1, PredecessorIndices="4+8", Description = "Description of Task 3/Child Task 2" },

                new TaskInfo { Name = "Grand Child Task 1", ID = 6, IndentLevel = 2, StartTime = dtStart, Effort = TimeSpan.Parse("08:00:00"), Description = "Description of Task 3/Child Task 1/Grand Child 1" },

                new TaskInfo { Name = "Grand Child Task 2", ID = 7, IndentLevel = 2, StartTime = dtStart, Effort = TimeSpan.Parse("16:00:00"), Description = "Description of Task 3/Child Task 1/Grand Child 2" },

                new TaskInfo { Name = "Child Task 3", ID = 8, IndentLevel = 1, StartTime = dtStart, Effort = TimeSpan.Parse("16:00:00"), Description = "Description of Task 3/Child Task 3" },

                new TaskInfo { Name = "Task 4", ID = 9, StartTime = dtStart, Effort = TimeSpan.Parse("08:00:00"),  ProgressPercent=30, Description = "Description of Task 4" },

                new TaskInfo { Name = "Task 5", ID = 10, PredecessorIndices = "3+8, 9", Description = "Description of Task 5" },//

                new TaskInfo { Name = "Child Task 1", ID = 11, IndentLevel = 1, StartTime = dtStart, Effort = TimeSpan.Parse("1.16:00:00"), Description = "Description of Task 5/Child Task 1" },

                new TaskInfo { Name = "Child Task 2", ID = 12, PredecessorIndices = "11SS+8", IndentLevel = 1, StartTime = dtStart, Effort = TimeSpan.Parse("08:00:00"), Description = "Description of Task 5/Child Task 2" },

                new TaskInfo { Name = "Task 6", ID = 13, StartTime = dtStart + TimeSpan.FromDays(2), Effort = TimeSpan.Parse("16:00:00"), Resources = "Resource 1", Description = "Description of Task 6" },

                new TaskInfo { Name = "Child Task 1", ID = 14, IndentLevel = 1, StartTime = dtStart, Effort = TimeSpan.Parse("20:00:00"), Resources = "Resource 2", Description = "Description of Task 6/Child Task 1" },

                new TaskInfo { Name = "Grand Child Task 1", ID = 15, StartTime=dtStart, Effort=TimeSpan.FromDays(1), IndentLevel = 2,  Description = "Description of Task 6/Child Task 2" }

            };


            // These resources should match the resource names specified in the above list.

            this.ganttControl1.ResourceItemsSource = new string[] { "Resource 1", "Resource 2" };


            // Assign the tasks to the GanttControl:

            this.ganttControl1.ItemsSource = taskItems;


        }


Build and run the project, this should display a Gantt control with all the tasks and their dependencies.


The Databinding section lists several other databinding options available.




� RadiantQ 2009 - 2019. All Rights Reserved.