Back to Devexpress

Mappings

wpf-400343-controls-and-libraries-gantt-control-bind-to-data-mappings.md

latest3.9 KB
Original Source

Mappings

  • Aug 09, 2023
  • 2 minutes to read

When you bind the GanttControl to a data source, you need to map the GanttNode properties to data source fields.

In real-world applications, the names of the database fields are usually fixed, and you cannot change them. Mappings are used to adjust the GanttControl data model to the existing data model.

MappingData TypeDescription
NameMappingStringMaps to the GanttNode.Name property. Provides a path to a data field that stores the task’s name.
ProgressMappingDoubleMaps to the GanttNode.Progress property. Provides a path to a data field that stores the task’s progress.
StartDateMappingDateTimeMaps to the GanttNode.StartDate property. Provides a path to a data field that stores the task’s start date.
FinishDateMappingDateTimeMaps to the GanttNode.FinishDate property. Provides a path to a data field that stores the task’s finish data.
DurationMappingTimeSpanMaps to the GanttNode.Duration property. Provides a path to a data field that stores the task’s duration.
BaselineStartDateMappingDateTimeMaps to the GanttNode.BaselineStartDate property. Provides a path to a data field that stores the task baseline’s start date.
BaselineFinishDateMappingDateTimeMaps to the GanttNode.BaselineFinishDate property. Provides a path to a data field that stores the task baseline’s finish date.
BaselineDurationMappingTimeSpanMaps to the GanttNode.BaselineDuration property. Provides a path to a data field that stores the task baseline’s duration.

The code sample below demonstrates how to specify mappings.

xaml
<dxgn:GanttControl ItemsSource="{Binding Tasks}">
    <dxgn:GanttControl.View>
        <dxgn:GanttView
            AutoExpandAllNodes="True"
            TreeDerivationMode="Selfreference"
            KeyFieldName="Id"
            ParentFieldName="ParentId"
            StartDateMapping="Start"
            FinishDateMapping="Finish"
            NameMapping="Name" />
    </dxgn:GanttControl.View>
</dxgn:GanttControl>

Tip

You have no need to specify mappings when the GanttControl is bound to a collection of GanttTask objects.

You can use the Mapping.Converter property to specify a value converter for your data:

xaml
<dxgn:GanttView.StartDateMapping>
    <dxgn:Mapping Path="BaselineStartDate" Converter="{StaticResource ...}"/>
</dxgn:GanttView.StartDateMapping>