Style Gantt Bars

5 posts, 0 answers
  1. Justin Lee
    Justin Lee avatar
    149 posts
    Member since:
    Dec 2009

    Posted 18 Jun 2012 Link to this post

    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
  2. Ventzi
    Ventzi avatar
    1 posts
    Member since:
    Jun 2012

    Posted 19 Jun 2012 Link to this post

    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
  3. DevCraft banner
  4. Justin Lee
    Justin Lee avatar
    149 posts
    Member since:
    Dec 2009

    Posted 19 Jun 2012 Link to this post

    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
  5. Justin Lee
    Justin Lee avatar
    149 posts
    Member since:
    Dec 2009

    Posted 19 Jun 2012 Link to this post

    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>
  6. AMO
    AMO avatar
    31 posts
    Member since:
    Nov 2011

    Posted 04 Jan 2013 Link to this post

    Justin,can you please provide a detailed answer ????
Back to Top
DevCraft banner