In my application (that references Gantt Chart controls from Gantt Chart Light Library) I have defined a CustomGanttChartItem object type inheriting from GanttChartItem adding custom properties to be displayed in the grid and/or referenced in custom task templates. However, I loading and saving Project XML files doesn't support loading and saving the custom item type and the custom values by default. Is there a way I can inject code to handle these situations?
If you want to import and/or export Project XML files from Gantt Chart components when you are using a CustomGanttChartItem object type inheriting from GanttChartItem and defining your own custom properties, you need to:
var loader = new GanttChartDataGrid.ProjectXmlSerializer(GanttChartDataGrid);
loader.GanttChartItemLoading +=
delegate(object sender, GanttChartView.ProjectXmlSerializer.GanttChartItemLoadingEventArgs e)
{
// Implement method yourself:
// CustomGanttChartItem GetNewItem(GanttChartItem partialItem, XElement sourceXml);
e.GanttChartItem = GetNewItem(e.GanttChartItem, e.SourceElement);
};
loader.Load(stream);
var saver = new GanttChartDataGrid.ProjectXmlSerializer(GanttChartDataGrid);
saver.GanttChartItemSaving +=
delegate(object sender, GanttChartView.ProjectXmlSerializer.GanttChartItemSavingEventArgs e)
{
// Implement method yourself:
// string GetXml(string partialXml, CustomGanttChartItem item);
e.OutputXml = GetXml(e.OutputXml, e.GanttChartItem as CustomGanttChartItem);
};
saver.Save(stream);