Bar chart color

2 posts, 0 answers
  1. Gyan
    Gyan avatar
    1 posts
    Member since:
    Jul 2012

    Posted 13 Nov 2012 Link to this post

    I want to set the bar color based on a property. I used a converter to do this but somehow the converter is not invoked.
    My code is below






    <!--<Rectangle Fill="#B0127F" Width="50" />-->


    <Rectangle Fill="{Binding ProjectStage, Converter={StaticResource StageToBrushConverter}}" Width="50" />





    The commented line shows something that works. But with the binding and converter it doesn't.
    What am I doing wrong?

  2. Victor
    Victor avatar
    1349 posts

    Posted 13 Nov 2012 Link to this post

    Hi Gyan,

    Thanks for writing.
    The XAML snippet that you posted does not work because you assume that the data context of the data template is your data object. In fact, it is an instance of the DataPoint class. This data point has a DataItem property which is a reference to your data object. So your binding should bind to DataItem.ProjectStage instead of just ProjectStage.

    Please write again if you need further assistance.

    the Telerik team
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
Back to Top