Color converter no being called on update

3 posts, 1 answers
  1. svs
    svs avatar
    5 posts
    Member since:
    Sep 2007

    Posted 20 May 2013 Link to this post

    I have a Cartesian chart as follows:

    <telerik:RadCartesianChart x:Name="chart" Grid.Column="0">
            <telerik:BarSeries ItemsSource="{Binding DataItems}" ValueBinding="Value" CategoryBinding="DayPeriod" >
                        <Rectangle Fill="{Binding Converter={StaticResource BrushConverter}, ConverterParameter={StaticResource brushes}}"/>
            <telerik:LinearAxis Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" MajorStep="{Binding StepSize}" LabelStyle="{StaticResource axisLabelStyle}" />
            <telerik:CategoricalAxis LabelFitMode="Rotate" LabelInterval="2"/>

    I'm setting the colour of each individual Bar in the BarSeries via an IValueConverter (blue for positive, red for negative) using a BrushCollection defined in the UserControl's resources passed into the Value Converted.
    It works very nicely!
    The Chart is bount to an ObservableCollection<t> of items implemention INotofyPropertyChanged. When the values change, the graph does indeed update - but it never calls the Color Converter and it the value goes from - to + or the other way around it ends up with the wrong colour.

    I can't see how to force this update. Is there a way?

    Thanks -

  2. Answer
    Petar Marchev
    Petar Marchev avatar
    968 posts

    Posted 23 May 2013 Link to this post

    Hi Simon,

    I think that the only problem is that the binding does not have a Path. The binding does not recall the converter because only a property of the DataPoint has changed and not the whole DataPoint (the DataContext of the Rectangle). I guess that in the Converter you get the Value of the DataPoint, so what you need to do is simply set a Path to the binding and update the converter as needed:
      <Rectangle Fill="{Binding Value, Converter=... />

    Petar Marchev

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
  4. svs
    svs avatar
    5 posts
    Member since:
    Sep 2007

    Posted 23 May 2013 Link to this post

    Petar -

    Thanks very much! You were quite right about what I was doing, and putting the Path in the rectangle did indeed fix it.

    Thank you -

Back to Top