public MainWindow()
{
InitializeComponent();
Gantt.CustomScheduleSource = GetCustomScheduleSource();
}
public IList<GanttScheduleRowInfo> GetCustomScheduleSource()
{
return new List<GanttScheduleRowInfo>
{
new GanttScheduleRowInfo
{
TimeUnit = TimeUnit.Days,
PixelsPerUnit = 45,
CellTextFormat = "dd"
},
new GanttScheduleRowInfo
{
TimeUnit = TimeUnit.Hours,
PixelsPerUnit = 30,
CellTextFormat = "hh"
}
};
}
|
<sync:GanttControl x:Name="Gantt"
ItemsSource="{Binding TaskCollection}"
ResourceCollection="{Binding ResourceCollection}"
VisualStyle="Metro" ScheduleType="CustomDateTime" >
<sync:GanttControl.TaskAttributeMapping>
<sync:TaskAttributeMapping TaskIdMapping="TaskId"
TaskNameMapping="TaskName"
StartDateMapping="StartDate"
ChildMapping="Child"
FinishDateMapping="FinishDate"
DurationMapping="Duration"
MileStoneMapping="IsMileStone"
ProgressMapping="Progress"
PredecessorMapping="Predecessor"
ResourceInfoMapping="Resources"/>
</sync:GanttControl.TaskAttributeMapping>
</sync:GanttControl> |
private void Gantt_Loaded(object sender, RoutedEventArgs e)
{
for(int i=0;i< Gantt.GanttGrid.InternalGrid.Columns.Count;i++)
{
var column = Gantt.GanttGrid.InternalGrid.Columns[i];
if (column.HeaderText == "Duration")
{
column.StyleInfo.TimeSpanEdit.Format = "hh:mm:ss";
}
else if(column.HeaderText == "Start" || column.HeaderText == "Finish")
{
column.StyleInfo.DateTimeEdit.DateTimePattern = Syncfusion.Windows.Shared.DateTimePattern.CustomPattern;
column.StyleInfo.DateTimeEdit.CustomPattern = "MM / dd / yyyy hh:mm:ss";
}
}
Gantt.GanttGrid.Model.ColumnWidths[4] = 180;
Gantt.GanttGrid.Model.ColumnWidths[3] = 180;
Gantt.GanttGrid.InternalGrid.InvalidateCells();
}
} |