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

Style Gantt Bars

4 Answers 96 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Justin Lee
Top achievements
Rank 1
Justin Lee asked on 18 Jun 2012, 09:27 PM
Is there anyway to color the bars?

I have a simple gantt chart.  I'm binding the gantt to a list of custom objects.  The custom objects have a property that specifies a color.  Is there anyway to get the bars in the gantt chart to reflect the color in the dataitem?

Thanks,
Justin

4 Answers, 1 is accepted

Sort by
0
Ventzi
Top achievements
Rank 1
answered on 19 Jun 2012, 03:22 PM
Hi Justin,

I had the same problem. I did it with setting the style of the EventContainer like this:

<Style TargetType="gantt:EventContainer">
       <Setter Property="Background" Value="Green"/>
       <Setter Property="BorderBrush" Value="Red"/>
       <Setter Property="BorderThickness" Value="1"/>
</Style>

where "gannt" point to Telerik.Windows.Controls.GanttView assembly.

I hope this helps ;)

Ventzi
0
Justin Lee
Top achievements
Rank 1
answered on 19 Jun 2012, 03:55 PM
Thanks for posting.  I'm looking to databind each bar's color, and you can't databind a setter of a style.  I'm guessing I'll have to define the style's template, but in reviewing the ganttview style, I'm struggling finding where to do this.  However your post got me further in that I now know EventContainer is the style of the bars.

Justin
0
Justin Lee
Top achievements
Rank 1
answered on 19 Jun 2012, 04:18 PM
Figured it out. 

For those looking to databind the bars colors:

Define the style of the EventContainer.  In the Template setter, find the border with the name "BackgroundBorder".  Set the background to the property in your dataitem.  The data context of the border will be an EventProxy, so you need to add Path=OriginalEvent.  So if your property is called "BarColor", the binding would be:  Background="{Binding Path=OriginalEvent.BarColor}".

Justin
<Style TargetType="gantt:EventContainer">
  ...
  <Setter Property="Template">
    ...
    <Border x:Name=BackgroundBorder 
      ...
      Background={Binding Path=OriginalEvent.BarColor}
      ...
    </Border>
  </Setter>
</Style>
0
AMO
Top achievements
Rank 1
answered on 04 Jan 2013, 10:47 AM
Justin,can you please provide a detailed answer ????
Tags
GanttView
Asked by
Justin Lee
Top achievements
Rank 1
Answers by
Ventzi
Top achievements
Rank 1
Justin Lee
Top achievements
Rank 1
AMO
Top achievements
Rank 1
Share this question
or