This is a migrated thread and some comments may be shown as answers.

Change Gantt Task color as per status

1 Answer 370 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Prolay
Top achievements
Rank 1
Prolay asked on 03 Dec 2012, 09:24 AM
Hi,

For a project level gantt chart i need to change the color of gantt task as per the project status. The possible project status can be more than two like Open, OnHold, Complete. Is there a way to change color based on condition.



Regards,
Prolay

1 Answer, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 05 Dec 2012, 08:58 AM
Hi Prolay,

The easiest way of doing this is to bind the Background property of the EventContainer control to the property of the GanttTask holding this information using a ValueConverter. Here is an example how to do this if you have a property called Background of type Brush in your custom GanttTask:
<telerik:RadGanttView VisibleRange="{Binding VisibleRange}" TasksSource="{Binding Tasks}">
    <telerik:RadGanttView.Resources>
        <Style TargetType="telerik:EventContainer">
            <Setter Property="Background" Value="{Binding OriginalEvent.Background}" />
        </Style>
    </telerik:RadGanttView.Resources>
</telerik:RadGanttView>

Here is the code of the custom GanttTask:
public class CustomTask : GanttTask
{
    private Brush background;
 
    /// <Summary>Gets or sets Background and notifies for changes</Summary>
    public Brush Background
    {
        get { return this.background; }
        set
        {
            if (this.background != value)
            {
                this.background = value;
                this.OnPropertyChanged(() => this.Background);
            }
        }
    }
}

Hope this helps.

Regards,
Miroslav Nedyalkov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GanttView
Asked by
Prolay
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Share this question
or