RadiantQ WPF Gantt
DataBinding
Previous Topic  Next Topic 

This scenario is illustrated in this sample: ...\Samples\FlexyGantt\DataBinding\FlexyGanttResourceView.


1. DataBinding Properties


The flexibility of the FlexyGantt is best expressed by its ability to directly data-bind to your complex hierarchical data structures.


For example, consider this data structure you might have to represent a hierarchy of resources:


Team        {TName, OverallStartTime, OverallEndTime, Employees}

   Employee   {EName, EmployeeTasks}

       Task   {TaskName, StartTime, EndTime}


Now you can bind the FlexyGantt to a list of Team instances as follows:


this.fxgantt.ItemsSource = teams;


But to properly resolve the hierarchy and point the gantt to the relevant properties in the control, you will have to define and set these properties:


2. Resolving the hieararchy


Specify a HierarchicalDataTemplate to resolve the hierarchy above (if your hierarchy is deeper you can define additional HierarchicalDataTemplate instances):


<!-- The template for the Employee level-->

<DataTemplate x:Key="TreeLeafTemplate">

                <TextBlock Text="{Binding Path=EName}" />

            </DataTemplate>

            <HierarchicalDataTemplate x:Key="TreeTemplate" ItemsSource="{Binding Path=Employees}"

                                            ItemTemplate="{StaticResource TreeLeafTemplate}">

                <TextBlock Text="{Binding Path=TName}" />

            </HierarchicalDataTemplate>


Then set the FlexyGantt.ItemTemplate property to the top-level HierarchicalDataTemplate above:


<fxgantt:FlexyGantt ItemTemplate="{StaticResource TreeTemplate}" />


This will define the "tree structure" for the list on the left and render the hierarchy in a tree.


You can then define a "flexyGanttTableTemplate" that will replace this tree with a multi-column tree list. For brevity, code for this is not included here. Please check this topic and/or the above sample referenced.


3. Binding to the Tasks list


Now you will have to define how to retrieve the tasks for each employee (leaf-nodes in the tree). This is done by specifying a Binding for the TaskListBinding property as follows:


<fxgantt:FlexyGantt TaskListBinding="{Binding EmployeeTasks}" >


Optionally, you can use converters to dynamically create this list from your "leaf-nodes" in the tree.


Also, if the leaf-node themselves are the tasks, then you can simply leave this property at null.


The summary Team object instances also includes time-information that is to be plotted in the gantt in their OverallStartTime and OverallEndTime properties. These are used in the next step. If the summary object instead had a list of tasks to be plotted, then you would use the ParentTaskListBinding setting along the same lines.


4. Binding to the start and end time for the Tasks list


This is done by specifying bindings on the TaskStartTimeBinding, TaskEndTimeBinding, ParentTaskStartTimeBinding and ParentTaskEndTimeBinding properties as follows:


<fxgantt:FlexyGantt TaskStartTimeBinding="{Binding StartTime}" TaskEndTimeBinding="{Binding EndTime}" ParentTaskStartTimeBinding="{Binding OverallStartTime}" ParentTaskEndTimeBinding="{Binding OverallEndTime}" >


The DataSource for these bindings will be the corresponding "task objects" as defined by the TaskListBinding setting above.


Finally, the look and feel of the tasks can be defined as described in this "Task Template" topic.



� RadiantQ 2009 - 2019. All Rights Reserved.