Customizing the Gantt Chart item template in GanttChartView and GanttChartDataGrid controls of Gantt Chart Light Library

For the most common scenarios, you can customize the Gantt Chart task bars presented by the GanttChartView, GanttChartDataGrid, ScheduleChartView, and ScheduleChartDataGrid controls from Gantt Chart Light Library by defining values for StandardTaskTemplate, SummaryTaskTemplate, and MilestoneTaskTemplate properties, specifying the user interface to be loaded for different types of task bars at runtime. For more information, see the Bar Templating sample (for Silverlight™ or for WPF).

However, if you also need to provide advanced customizations for the internal, generic Gantt Chart item template, you may start from the built in code of ItemTemplate property definition presented below. Actually, by default we use a TaskPresenter object instance instead (to provide further runtime performance optimizations automatically), but the user interface initialization code below is otherwise exactly the same:

<DataTemplate>
    <DataTemplate.Resources>
        <DataTemplate x:Key="ContentDataTemplate">
            <Grid Visibility="{Binding Visibility}" Height="{Binding GanttChartView.ItemHeight}">
                <ItemsControl ItemsSource="{Binding Predecessors}" Height="0" HorizontalAlignment="Left"
                              VerticalAlignment="Center"
                              Visibility="{Binding GanttChartView.TaskDependenciesVisibility}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <Grid/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <pdgcc:DependencyLinePresenter
                                Visibility="{Binding ComputedDependencyLineVisibility}"/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
                    <ToolTipService.ToolTip>
                        <ToolTip Content="{Binding}" ContentTemplate="{Binding GanttChartView.ToolTipTemplate}"
                                 Visibility="{Binding GanttChartView.TaskToolTipVisibility}"/>
                    </ToolTipService.ToolTip>
                    <Grid Width="{Binding ComputedBarWidth}" Height="{Binding ComputedBarHeight}">
                        <ContentControl Content="{Binding}" ContentTemplate="{Binding ComputedTaskTemplate}"
                                        HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                        HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
                                        IsTabStop="False"/>
                    </Grid>
                    <Grid Width="4">
                        <Grid Visibility="{Binding GanttChartView.ThumbVisibility}">
                            <pdgcc:DragDependencyThumb Height="{Binding ComputedBarHeight}"
                                Visibility="{Binding GanttChartView.DependencyCreationThumbVisibility}"/>
                        </Grid>
                    </Grid>
                    <ContentControl Content="{Binding}"
                                    ContentTemplate="{Binding GanttChartView.AssignmentsTemplate}" Margin="3,0"
                                    VerticalAlignment="Center" IsHitTestVisible="False" IsTabStop="False"/>
                </StackPanel>
            </Grid>
        </DataTemplate>
    </DataTemplate.Resources>
    <ContentControl x:Name="ContentControl" Content="{Binding}" ContentTemplate="{StaticResource ContentDataTemplate}"/>
</DataTemplate>