RadiantQ WPF Gantt
EndTime field without Effort field
Previous Topic  Next Topic 

Often, you might have a data source with EndTime field rather than an Effort field for a task. 


In such cases, you have to first setup EffortBinding usinsg a converter as follows:



     // In XAML:   

       <gantt:GanttControl x:Name="ganttControl" Grid.Column="1" IDBinding="{Binding TaskID, Mode=TwoWay}"

                           EffortBinding="{Binding EndTime, Converter={StaticResource effortconverter}}"                                       EndTimeBinding="{Binding EndTime, Mode=TwoWay}"

                       ....................      

                           >           

        </gantt:GanttControl>


    public class EffortConverter : IValueConverter

    {

       CustomTask task;

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

        {

            task = (CustomTask)parameter;

            return GetTaskEffort(task);

        }


        private object GetTaskEffort(CustomTask task)

        {


            if (task.StartTime != null && task.EndTime != null && task.StartTime != DateTime.MinValue && task.EndTime != DateTime.MinValue)

            {

                // Note that "WorkTimeSchedule.Schedule8X5" is the same schdule used by the GanttControl

                // in this app. If you use a different schedule in the GanttControl, use that same schedule here as well:

                return RadiantQ.Windows.Controls.Gantt.WorkTimeSchedule.Schedule8X5.GetEffort(task.StartTime, task.EndTime);

            }

            return TimeSpan.Zero;

        }


        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

        {

            throw new Exception("Not implemented.");

        }

       

    }




Also above, see how you will have to setup the EndTimeBinding so that changes made to the EndTime are persisted back into your data's EndTime property. 


This is also illustrated in this sample that's part of our install: <install path>\Samples\Project\DataBinding\GanttControlBindingToEndTime

(The above sample also sets the AdjustDurationOnAssignment property to false to make the gantt work in "Fixed Duration" mode. You can choose to keep it true to make the gantt adjust the duration of a task when multiple assignments are made.)



� RadiantQ 2009 - 2019. All Rights Reserved.